@dst-justin/relay 2.1.1 → 2.1.2
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/README.md +16 -0
- package/package.json +1 -1
- package/relay +65 -26
package/README.md
CHANGED
|
@@ -218,3 +218,19 @@ Sessions live in `~/.claude/projects/` and are shared across all accounts — af
|
|
|
218
218
|
| `relay.ps1` | Full PowerShell implementation |
|
|
219
219
|
| `relay.cmd` | Thin CMD wrapper — delegates to `relay.ps1` |
|
|
220
220
|
|
|
221
|
+
|
|
222
|
+
---
|
|
223
|
+
|
|
224
|
+
## Changelog
|
|
225
|
+
|
|
226
|
+
### v2.1.1 — 2026-06-24
|
|
227
|
+
- Display current version and latest version at the end of `list`, `status`, `relay` (menu), `sessions`, and `help` commands
|
|
228
|
+
- Background version check (24h cache) — non-blocking, never slows down output
|
|
229
|
+
- `relay update` now detects original install method: uses `npm install -g` for npm installs, `git pull` for git clones, and direct GitHub download for bare script copies
|
|
230
|
+
- `npm install -g` post-install script automatically patches `~/.bashrc`, `~/.zshrc`, `~/.profile`, and fish `config.fish` if the npm bin dir is missing from PATH
|
|
231
|
+
|
|
232
|
+
### v2.1.0 — 2026-06-24
|
|
233
|
+
- Upgraded GitHub Actions workflow to `actions/checkout@v6` and `actions/setup-node@v6` (Node 24 runtime, removes Node 20 deprecation warning)
|
|
234
|
+
|
|
235
|
+
### v2.0.2 — 2026-06-23
|
|
236
|
+
- Skip `npm install` during `relay update` when already on the latest version or when version check fails
|
package/package.json
CHANGED
package/relay
CHANGED
|
@@ -908,47 +908,74 @@ cmd_autoswitch_config() {
|
|
|
908
908
|
exit 1
|
|
909
909
|
fi
|
|
910
910
|
|
|
911
|
+
# ── Step 1: switch order ───────────────────────────────────────
|
|
911
912
|
echo ""
|
|
912
|
-
printf "
|
|
913
|
-
|
|
914
|
-
|
|
913
|
+
printf " ${B}Step 1 / 3 — Switch order${R}\n"
|
|
914
|
+
printf " ${D}When an account hits its threshold, relay switches to the next one in order.${R}\n\n"
|
|
915
|
+
local i=1
|
|
916
|
+
for acct in "${accounts[@]}"; do
|
|
917
|
+
printf " ${D}%d${R} %s\n" "${i}" "${acct}"
|
|
918
|
+
i=$((i+1))
|
|
919
|
+
done
|
|
920
|
+
echo ""
|
|
921
|
+
printf " ${D}Type numbers in the order you want (e.g. ${CY}2 1${D} or just Enter to keep the order above):${R}\n"
|
|
915
922
|
printf " > "; read -r order_input
|
|
916
|
-
local order_str; order_str=$(echo "${order_input}" | "${PY}" -c "
|
|
917
|
-
import sys,re
|
|
918
|
-
raw=sys.stdin.read().strip()
|
|
919
|
-
names=[x.strip() for x in raw.split(',') if x.strip()]
|
|
920
|
-
print(','.join(names))")
|
|
921
923
|
|
|
924
|
+
# resolve numbers (space or comma) to names; empty = default order
|
|
925
|
+
local order_str; order_str=$(echo "${order_input}" | "${PY}" - "${accounts[@]}" <<'PYEOF'
|
|
926
|
+
import sys, re
|
|
927
|
+
raw = sys.stdin.read().strip()
|
|
928
|
+
accts = sys.argv[1:]
|
|
929
|
+
if not raw:
|
|
930
|
+
print(','.join(accts))
|
|
931
|
+
else:
|
|
932
|
+
tokens = re.split(r'[\s,]+', raw)
|
|
933
|
+
result = []
|
|
934
|
+
for t in tokens:
|
|
935
|
+
t = t.strip()
|
|
936
|
+
if t.isdigit():
|
|
937
|
+
idx = int(t) - 1
|
|
938
|
+
if 0 <= idx < len(accts): result.append(accts[idx])
|
|
939
|
+
elif t:
|
|
940
|
+
result.append(t)
|
|
941
|
+
print(','.join(result))
|
|
942
|
+
PYEOF
|
|
943
|
+
)
|
|
944
|
+
# show resolved order as a visual chain
|
|
945
|
+
local chain; chain=$(echo "${order_str}" | "${PY}" -c "
|
|
946
|
+
import sys; names=sys.stdin.read().strip().split(',')
|
|
947
|
+
print(' → '.join(names) + ' → (cycle)')")
|
|
948
|
+
printf " ${D}Order: ${CY}%s${R}\n" "${chain}"
|
|
949
|
+
|
|
950
|
+
# ── Step 2: thresholds ────────────────────────────────────────
|
|
922
951
|
echo ""
|
|
923
|
-
printf " ${B}
|
|
952
|
+
printf " ${B}Step 2 / 3 — Thresholds${R}\n"
|
|
953
|
+
printf " ${D}Autoswitch triggers when an account's 5-hr usage exceeds this %%.${R}\n"
|
|
954
|
+
printf " ${D}Enter a number (e.g. 70), or press Enter for default 80%%.${R}\n\n"
|
|
955
|
+
|
|
924
956
|
local thresholds_json="{"
|
|
925
957
|
local order_json="["
|
|
926
|
-
local
|
|
927
|
-
local first_thresh=1
|
|
958
|
+
local first=1
|
|
928
959
|
IFS=',' read -ra order_arr <<< "${order_str}"
|
|
929
960
|
for acct in "${order_arr[@]}"; do
|
|
930
|
-
printf " %s threshold
|
|
961
|
+
printf " ${CY}%s${R} threshold [80%%]: " "${acct}"
|
|
931
962
|
read -r val
|
|
932
|
-
|
|
933
|
-
|
|
934
|
-
fi
|
|
935
|
-
[[ ${first_order} -eq 0 ]] && order_json+=","
|
|
963
|
+
[[ -z "${val}" ]] && val="80"
|
|
964
|
+
[[ ${first} -eq 0 ]] && { order_json+=","; thresholds_json+=","; }
|
|
936
965
|
order_json+="\"${acct}\""
|
|
937
|
-
first_order=0
|
|
938
|
-
[[ ${first_thresh} -eq 0 ]] && thresholds_json+=","
|
|
939
966
|
thresholds_json+="\"${acct}\":${val}"
|
|
940
|
-
|
|
967
|
+
first=0
|
|
941
968
|
done
|
|
942
969
|
order_json+="]"
|
|
943
970
|
thresholds_json+="}"
|
|
944
971
|
|
|
972
|
+
# ── Step 3: poll interval ─────────────────────────────────────
|
|
945
973
|
echo ""
|
|
946
|
-
printf " ${B}
|
|
947
|
-
|
|
948
|
-
printf "
|
|
949
|
-
read -r high_min; high_min="${high_min:-2}"
|
|
950
|
-
printf "
|
|
951
|
-
read -r high_thr; high_thr="${high_thr:-50}"
|
|
974
|
+
printf " ${B}Step 3 / 3 — Check interval${R}\n"
|
|
975
|
+
printf " ${D}How often the daemon checks usage. Switches to faster polling near the threshold.${R}\n\n"
|
|
976
|
+
printf " Normal check every N minutes [10]: "; read -r low_min; low_min="${low_min:-10}"
|
|
977
|
+
printf " Fast check every N minutes [2]: "; read -r high_min; high_min="${high_min:-2}"
|
|
978
|
+
printf " Switch to fast polling at [50%%]: "; read -r high_thr; high_thr="${high_thr:-50}"
|
|
952
979
|
|
|
953
980
|
local cfg_file="${RELAY_DIR}/autoswitch.json"
|
|
954
981
|
printf '{"order":%s,"thresholds":%s,"poll":{"low_minutes":%s,"high_minutes":%s,"high_threshold":%s}}' \
|
|
@@ -957,7 +984,19 @@ print(','.join(names))")
|
|
|
957
984
|
> "${cfg_file}"
|
|
958
985
|
|
|
959
986
|
echo ""
|
|
960
|
-
ok "
|
|
987
|
+
ok "Config saved to ${cfg_file}"
|
|
988
|
+
echo ""
|
|
989
|
+
"${PY}" -c "
|
|
990
|
+
import json, sys
|
|
991
|
+
cfg = json.load(open(sys.argv[1]))
|
|
992
|
+
R='\033[0m'; B='\033[1m'; D='\033[2m'; CY='\033[36m'
|
|
993
|
+
for i, name in enumerate(cfg['order'], 1):
|
|
994
|
+
thr = cfg['thresholds'].get(name, '?')
|
|
995
|
+
print(f' {D}{i}.{R} {name:<14} → switch at {CY}{thr}%{R}')
|
|
996
|
+
p = cfg['poll']
|
|
997
|
+
print(f\"\n {D}polling: {p[\"low_minutes\"]}min normal / {p[\"high_minutes\"]}min fast (fast above {p[\"high_threshold\"]}%){R}\")
|
|
998
|
+
" "${cfg_file}"
|
|
999
|
+
echo ""
|
|
961
1000
|
log "Run ${CY}relay autoswitch start${R} to activate"
|
|
962
1001
|
}
|
|
963
1002
|
|