codeam-cli 2.4.14 → 2.4.16

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
@@ -4,6 +4,18 @@ All notable changes to `codeam-cli` are documented here.
4
4
 
5
5
  The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
6
6
 
7
+ ## [2.4.15] — 2026-05-03
8
+
9
+ ### Fixed
10
+
11
+ - **cli:** Robust pm2 wrapper for codeam deploy (v2.4.15)
12
+
13
+ ## [2.4.14] — 2026-05-03
14
+
15
+ ### Fixed
16
+
17
+ - **cli:** Use PM2 to keep codeam-pair alive on Codespaces (v2.4.14)
18
+
7
19
  ## [2.4.13] — 2026-05-03
8
20
 
9
21
  ### Fixed
package/dist/index.js CHANGED
@@ -179,7 +179,7 @@ var import_qrcode_terminal = __toESM(require("qrcode-terminal"));
179
179
  // package.json
180
180
  var package_default = {
181
181
  name: "codeam-cli",
182
- version: "2.4.14",
182
+ version: "2.4.16",
183
183
  description: "Remote control Claude Code (and other AI coding agents) from your mobile phone. Pair your device, send prompts, stream responses in real-time, and approve commands \u2014 from anywhere.",
184
184
  main: "dist/index.js",
185
185
  bin: {
@@ -5910,17 +5910,59 @@ async function deploy() {
5910
5910
  "pm2 delete codeam-pair >/dev/null 2>&1",
5911
5911
  // Start codeam pair under PM2. `--merge-logs` writes stdout
5912
5912
  // and stderr to the same file so we only need one tail.
5913
- 'pm2 start codeam --name codeam-pair --cwd "$PROJECT_DIR" -o "$LOG" -e "$LOG" --merge-logs --time -- pair >/dev/null 2>&1',
5914
- 'tail -n 0 -F "$LOG" 2>/dev/null &',
5913
+ // --max-restarts 3 keeps PM2 from looping forever if codeam pair
5914
+ // can't start (e.g. backend unreachable) three attempts is
5915
+ // enough for transient flakes, anything more wastes time.
5916
+ // No `--time` (would prefix every line with a timestamp and
5917
+ // break the QR rendering); no `--no-pmx` either (default off).
5918
+ 'pm2 start codeam --name codeam-pair --cwd "$PROJECT_DIR" --max-restarts 3 -o "$LOG" -e "$LOG" --merge-logs -- pair >/dev/null 2>&1',
5919
+ // Give PM2 a moment to spawn the process before we start polling
5920
+ // status — otherwise the very first jlist can race the spawn.
5921
+ "sleep 2",
5922
+ // Filter the live tail: PM2 captures stdout to a file, so codeam-
5923
+ // cli's spinner (which uses \r to redraw a single line in a TTY)
5924
+ // becomes hundreds of new "Waiting for mobile app" / "Requesting
5925
+ // pairing code" lines per second in the file — pure noise. Drop
5926
+ // them so the user sees just the QR + the pairing code + the
5927
+ // "Paired with" / "for shortcuts" markers.
5928
+ 'tail -n 0 -F "$LOG" 2>/dev/null | grep --line-buffered -vE "Waiting for mobile app|Requesting pairing code" &',
5915
5929
  "TAIL=$!",
5916
5930
  "trap 'kill $TAIL 2>/dev/null; exit 130' INT TERM",
5917
- // Phase 1 — wait for "Paired with".
5931
+ // Phase 1 — wait for "Paired with", or for codeam to print a
5932
+ // recognisable failure, or for PM2 to report the process gone.
5918
5933
  "SUCCESS=0",
5934
+ 'FAIL_REASON=""',
5919
5935
  "while true; do",
5920
5936
  ' if grep -q "Paired with" "$LOG" 2>/dev/null; then SUCCESS=1; break; fi',
5921
- ` STATUS=$(pm2 jlist 2>/dev/null | grep -o '"name":"codeam-pair","[^}]*"status":"[^"]*"' | grep -o '"status":"[^"]*"' | head -1)`,
5922
- ' if [ -z "$STATUS" ]; then SUCCESS=0; break; fi',
5923
- ' if echo "$STATUS" | grep -q "stopped\\|errored"; then SUCCESS=0; break; fi',
5937
+ // Detect specific codeam error messages early so the user gets
5938
+ // an actionable message instead of a generic "did not start".
5939
+ ' if grep -q "Could not reach the server" "$LOG" 2>/dev/null; then',
5940
+ ' FAIL_REASON="codeam could not reach the CodeAgent backend (network/firewall? Vercel bot-challenge on the API?)"',
5941
+ " SUCCESS=0; break",
5942
+ " fi",
5943
+ ' if grep -qE "Pairing timed out|Failed to" "$LOG" 2>/dev/null; then',
5944
+ ' FAIL_REASON="$(grep -E "Pairing timed out|Failed to" "$LOG" | head -1)"',
5945
+ " SUCCESS=0; break",
5946
+ " fi",
5947
+ // Status check: parse PM2 jlist via Python (every codespace has
5948
+ // python3) for resilient JSON handling, instead of fragile grep.
5949
+ ' ALIVE=$(pm2 jlist 2>/dev/null | python3 -c "import json,sys',
5950
+ "try:",
5951
+ " d=json.load(sys.stdin)",
5952
+ " it=[x for x in d if x.get('name')=='codeam-pair']",
5953
+ " print(it[0]['pm2_env']['status'] if it else 'missing')",
5954
+ "except Exception:",
5955
+ ` print('parse-error')" 2>/dev/null)`,
5956
+ ' case "$ALIVE" in',
5957
+ " online|launching) ;;",
5958
+ // still good
5959
+ ' "")',
5960
+ ' FAIL_REASON="PM2 not responding"',
5961
+ " SUCCESS=0; break ;;",
5962
+ " missing|stopped|errored|stopping)",
5963
+ ' FAIL_REASON="PM2 reports codeam-pair is $ALIVE"',
5964
+ " SUCCESS=0; break ;;",
5965
+ " esac",
5924
5966
  " sleep 1",
5925
5967
  "done",
5926
5968
  'if [ "$SUCCESS" = "1" ]; then',
@@ -5945,7 +5987,11 @@ async function deploy() {
5945
5987
  ' echo " To stop later: gh codespace ssh -- pm2 delete codeam-pair"',
5946
5988
  " exit 0",
5947
5989
  "else",
5948
- ' echo "\u2717 Pairing did not complete (codeam pair did not start)."',
5990
+ ' echo "\u2717 Pairing did not complete."',
5991
+ ' if [ -n "$FAIL_REASON" ]; then echo " Reason: $FAIL_REASON"; fi',
5992
+ " echo",
5993
+ ' echo " Last log lines from codeam pair:"',
5994
+ ' tail -n 8 "$LOG" 2>/dev/null | sed "s/^/ /"',
5949
5995
  " pm2 delete codeam-pair >/dev/null 2>&1",
5950
5996
  " exit 1",
5951
5997
  "fi"
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "codeam-cli",
3
- "version": "2.4.14",
3
+ "version": "2.4.16",
4
4
  "description": "Remote control Claude Code (and other AI coding agents) from your mobile phone. Pair your device, send prompts, stream responses in real-time, and approve commands — from anywhere.",
5
5
  "main": "dist/index.js",
6
6
  "bin": {