slack-term 1.46.0 → 1.48.0

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 CHANGED
@@ -435,8 +435,8 @@ slack stream --grep '<@U00000001>' --replies-to self --json # + every reply in
435
435
  between printing a match and saving the cursor repeats that line, so dedupe on
436
436
  `channel.id + ts`. A lock file keeps two streams off the same state.
437
437
  - **Transport: the relay is the primary mode; polling is the fallback.** Deploy
438
- [`worker/`](worker/) (a Cloudflare Worker on Slack's Events API — setup in
439
- [worker/README.md](worker/README.md)) and set `SLACK_RELAY_URL` and
438
+ the relay (a Cloudflare Worker on Slack's Events API — see
439
+ [Setting up the relay](#setting-up-the-relay)) and set `SLACK_RELAY_URL` and
440
440
  `SLACK_RELAY_TOKEN`: the stream then hears a *doorbell* — `{channel, ts, thread_ts}`,
441
441
  no text — within a second of each post, reads that one message through the Web API
442
442
  with its own token and runs it through the same `--grep`. While the relay is
@@ -444,6 +444,9 @@ slack stream --grep '<@U00000001>' --replies-to self --json # + every reply in
444
444
  when the relay is down it goes back to `--interval`. Both paths share one record of
445
445
  what was printed, so a message is never printed twice. The relay is used only when
446
446
  streaming as the bot (it rings for the bot's channels) and never with `--once`.
447
+ The connection is a WebSocket (the relay hibernates between bells, so an idle
448
+ connection costs next to nothing); against a relay deployed before that, it falls
449
+ back to Server-Sent Events. `SLACK_RELAY_TRANSPORT=websocket|sse` pins one.
447
450
  - **Polling fallback** (no relay configured, `--as-user`, or `--no-relay`). The stream
448
451
  prints a `WARNING: polling mode` line on stderr, pointing to the relay setup. It
449
452
  polls every `--interval` (default `45s`), paced to stay inside Slack's rate limits:
@@ -468,6 +471,34 @@ slack stream --grep '<@U00000001>' --replies-to self --json # + every reply in
468
471
  SIGINT/SIGTERM; `2` `--once` found nothing; `3` transport/auth failure (stderr says
469
472
  which); `1` bad arguments (e.g. an invalid regex).
470
473
 
474
+ #### Setting up the relay
475
+
476
+ No clone needed — the relay ships in the npm package as `slack-term/worker`:
477
+
478
+ ```sh
479
+ slack relay init my-relay # writes package.json, wrangler.jsonc, src/index.ts, .gitignore, README.md
480
+ ```
481
+
482
+ It writes local files only (no network; refuses to overwrite without `--force`) and
483
+ prints a freshly generated `RELAY_TOKEN` (never saved to disk) with the next steps:
484
+ `npm install`, `npx wrangler login` (or `CLOUDFLARE_API_TOKEN` + `CLOUDFLARE_ACCOUNT_ID`),
485
+ `npx wrangler deploy` (Node ≥ 22), `wrangler secret put SLACK_SIGNING_SECRET` /
486
+ `RELAY_TOKEN` / optional `SLACK_TEAM_ID`, then the Slack app's Event Subscriptions
487
+ Request URL `https://<worker>/slack/events`. Check it with `slack relay health`
488
+ (GET `/health` using `SLACK_RELAY_URL` / `SLACK_RELAY_TOKEN`) and `slack stream`,
489
+ which says `relay connected (websocket)`.
490
+
491
+ An existing Worker project needs only the re-export (plus the `RELAY` Durable
492
+ Object binding and a `new_sqlite_classes: ["Relay"]` migration in wrangler config):
493
+
494
+ ```ts
495
+ // src/index.ts
496
+ export { default, Relay } from "slack-term/worker";
497
+ ```
498
+
499
+ Endpoints, privacy and protocol: [worker/README.md](worker/README.md), which also
500
+ covers deploying straight from a clone of this repo (for contributors).
501
+
471
502
  ## Configuration
472
503
 
473
504
  Requires a Slack user token (`xoxp-...`) with the following scopes:
package/SKILL.md CHANGED
@@ -54,8 +54,9 @@ slack msgs
54
54
 
55
55
  # Every new message matching a regex, across all channels + threads (long-running;
56
56
  # resumable cursor; as the bot when SLACK_BOT_TOKEN is set). Exit 0 match / 2 none / 3 failure.
57
- # Real time = the relay (primary mode): deploy worker/ (see worker/README.md) and set
58
- # SLACK_RELAY_URL + SLACK_RELAY_TOKEN. Without it the stream falls back to POLLING and
57
+ # Real time = the relay (primary mode): `slack relay init` scaffolds a Cloudflare Worker
58
+ # (local files only; prints a RELAY_TOKEN and the deploy steps), then set
59
+ # SLACK_RELAY_URL + SLACK_RELAY_TOKEN; `slack relay health` checks it. Without it the stream falls back to POLLING and
59
60
  # warns on stderr ("WARNING: polling mode") — a fallback only: paced (--calls-per-min 40),
60
61
  # cursor-only reads each --interval (45s), full --thread-window re-read every --thread-scan (3m).
61
62
  slack stream --grep '<@U00000001>|@mybot' --json