diff --git a/CHANGELOG.md b/CHANGELOG.md index 3b5a7463a..ee61b3850 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,7 @@ - New `warelay heartbeat` CLI triggers a one-off heartbeat (web provider, auto-detects logged-in session; optional `--to` override). Relay gains `--heartbeat-now` to fire an immediate heartbeat on startup. - Added `warelay relay:heartbeat` (no tmux) and `warelay relay:heartbeat:tmux` helpers to start relay with an immediate startup heartbeat. - Relay now prints the active file log path and level on startup so you can tail logs without attaching. +- Heartbeat CLI accepts `--session-id` to force resuming a specific Claude session; fallback heartbeats skip instead of creating a new session when no stored session exists. - Heartbeat session handling now supports `inbound.reply.session.heartbeatIdleMinutes` and does not refresh `updatedAt` on skipped heartbeats, so sessions still expire on idle. - Web inbound now resolves WhatsApp Linked IDs (`@lid`) using Baileys’ reverse mapping files, so new-format senders are no longer dropped. - `allowFrom: ["*"]` is honored for auto-replies; manual heartbeats require `--to` or `--all` when multiple sessions exist or the allowlist is wildcard-only. diff --git a/README.md b/README.md index c337910ee..b39fead46 100644 --- a/README.md +++ b/README.md @@ -43,7 +43,7 @@ Install from npm (global): `npm install -g warelay` (Node 22+). Then choose **on | `warelay send` | Send a WhatsApp message (Twilio or Web) | `--to ` `--message ` `--wait ` `--poll ` `--provider twilio\|web` `--json` `--dry-run` `--verbose` | | `warelay relay` | Auto-reply loop (poll Twilio or listen on Web) | `--provider ` `--interval ` `--lookback ` `--verbose` | | `warelay status` | Show recent sent/received messages | `--limit ` `--lookback ` `--json` `--verbose` | -| `warelay heartbeat` | Trigger one heartbeat poll (web) | `--provider ` `--to ` `--all` `--verbose` | +| `warelay heartbeat` | Trigger one heartbeat poll (web) | `--provider ` `--to ` `--session-id ` `--all` `--verbose` | | `warelay relay:heartbeat` | Run relay with an immediate heartbeat (no tmux) | `--provider ` `--verbose` | | `warelay relay:heartbeat:tmux` | Start relay in tmux and fire a heartbeat on start (web) | _no flags_ | | `warelay webhook` | Run inbound webhook (`ingress=tailscale` updates Twilio; `none` is local-only) | `--ingress tailscale\|none` `--port ` `--path ` `--reply ` `--verbose` `--yes` `--dry-run` | @@ -125,7 +125,7 @@ Best practice: use a dedicated WhatsApp account (separate SIM/eSIM or business a - When `heartbeatMinutes` is set (default 30 for `mode: "command"`), the relay periodically runs your command/Claude session with a heartbeat prompt. - If Claude replies exactly `HEARTBEAT_OK`, the message is suppressed; otherwise the reply (or media) is forwarded. Suppressions are still logged so you know the heartbeat ran. - Override session freshness for heartbeats with `session.heartbeatIdleMinutes` (defaults to `session.idleMinutes`). Heartbeat skips do **not** bump `updatedAt`, so sessions still expire normally. -- Trigger one manually with `warelay heartbeat` (web provider only, `--verbose` prints session info). Use `warelay relay:heartbeat` for a full relay run with an immediate heartbeat, or `--heartbeat-now` on `relay`/`relay:heartbeat:tmux`. +- Trigger one manually with `warelay heartbeat` (web provider only, `--verbose` prints session info). Use `--session-id ` to force resuming a specific Claude session, `--all` to ping every active session, `warelay relay:heartbeat` for a full relay run with an immediate heartbeat, or `--heartbeat-now` on `relay`/`relay:heartbeat:tmux`. - When multiple active sessions exist, `warelay heartbeat` requires `--to ` or `--all`; if `allowFrom` is just `"*"`, you must choose a target with one of those flags. ### Logging (optional) diff --git a/docs/heartbeat.md b/docs/heartbeat.md index 75bbae96b..77c58db0f 100644 --- a/docs/heartbeat.md +++ b/docs/heartbeat.md @@ -14,6 +14,7 @@ Goal: add a simple heartbeat poll for command-based auto-replies (Claude-driven) ## Poller behavior - When relay runs with command-mode auto-reply, start a timer with the resolved heartbeat interval. - Each tick invokes the configured command with a short heartbeat body (e.g., “(heartbeat) summarize any important changes since last turn”) while reusing the active session args so Claude context stays warm. +- Heartbeats never create a new session implicitly: if there’s no stored session for the target (fallback path), the heartbeat is skipped instead of starting a fresh Claude session. - Abort timer on SIGINT/abort of the relay. ## Sentinel handling @@ -37,6 +38,7 @@ Goal: add a simple heartbeat poll for command-based auto-replies (Claude-driven) - Add a short README snippet under configuration showing `heartbeatMinutes` and the sentinel rule. - Expose CLI triggers: - `warelay heartbeat` (web provider, defaults to first `allowFrom`; optional `--to` override) + - `--session-id ` forces resuming a specific session for that heartbeat - `warelay relay:heartbeat` to run the relay loop with an immediate heartbeat (no tmux) - `warelay relay:heartbeat:tmux` to run the same in tmux (detached, attachable) - Relay supports `--heartbeat-now` to fire once at startup (including the tmux helper).