Skip to content

Add fmsg watch: stream WebSocket events - #14

Merged
markmnl merged 2 commits into
mainfrom
watch
Aug 15, 2026
Merged

Add fmsg watch: stream WebSocket events#14
markmnl merged 2 commits into
mainfrom
watch

Conversation

@markmnl

Copy link
Copy Markdown
Owner

Summary

  • New fmsg watch [--events types] [--once] [--timeout D] command wrapping GET /fmsg/ws (upstream ask from fmsg-mcp-claude: OPEN_QUESTIONS remove wait command (route removed from web API) #8).
  • internal/api.Client.Watch: bearer token in the Authorization header (never the query string), 401 retried once with a refreshed token, auto-reconnect with backoff, pings answered and read deadline renewed.
  • --json emits NDJSON: {"type":"ready"} after every (re)connect so scripts know when to do a list catch-up, then one envelope per event (data in the list item shape).
  • Exit codes: 0 after an event / Ctrl-C, 2 when --once/--timeout ended before any event, 1 on error.
  • Adds github.com/gorilla/websocket (same lib as fmsg-webapi). README updated.

Test plan

  • Unit tests with an httptest WebSocket server (header auth, 401 refresh, passthrough, stop, reconnect + ready, cancel, 403)
  • Live against fmsg.live: --json watch --once printed ready then the new_msg for a message sent meanwhile; quiet --timeout exits 2
  • fmsg-docker integration test 010 (markmnl/fmsg-docker PR, run with FMSG_CLI_REF=watch) — passes

🤖 Generated with Claude Code

markmnland others added 2 commits August 5, 2026 11:05
The API's PUT replaces the whole draft; update sent only the provided
fields, silently wiping recipients, pid, topic, and body. Fetch the
current draft first and merge the changed flags over it, making the
documented PATCH-style semantics true.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
…ts_added)
Wraps GET /fmsg/ws. Token in the Authorization header (401 retried once
with a refreshed token), auto-reconnect with backoff, pings answered and
the read deadline renewed. --json emits NDJSON with a {"type":"ready"}
line after each (re)connect so scripts can catch up with list; --once and
--timeout for one-shot use; exit 2 when no event arrived.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant

@markmnl