slack-term 1.47.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 +30 -2
- package/SKILL.md +3 -2
- package/dist/cli.js +230 -166
- package/package.json +14 -1
- package/ts/cli.ts +45 -3
- package/ts/relayInit.ts +209 -0
- package/ts/stream.ts +1 -1
- package/worker/README.md +216 -0
- package/worker/src/hub.ts +203 -0
- package/worker/src/index.ts +308 -0
- package/worker/src/slack.ts +127 -0
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
|
-
|
|
439
|
-
[
|
|
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
|
|
@@ -471,6 +471,34 @@ slack stream --grep '<@U00000001>' --replies-to self --json # + every reply in
|
|
|
471
471
|
SIGINT/SIGTERM; `2` `--once` found nothing; `3` transport/auth failure (stderr says
|
|
472
472
|
which); `1` bad arguments (e.g. an invalid regex).
|
|
473
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
|
+
|
|
474
502
|
## Configuration
|
|
475
503
|
|
|
476
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):
|
|
58
|
-
#
|
|
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
|