@zksecurity/slack-events 0.2.0 → 0.2.1

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
@@ -73,7 +73,7 @@ slack-events history C012345 --limit 50 --cursor NEXT_CURSOR
73
73
  slack-events thread C012345 1788881468.871969 --limit 50
74
74
  slack-events file F012345
75
75
  slack-events download F012345 ./attachment.pdf
76
- slack-events listen --resolve
76
+ slack-events listen
77
77
  ```
78
78
 
79
79
  Use `users` and `channels` to discover IDs before making individual reads. They return Slack JSON with `members` or `channels` arrays containing IDs and names. `channels` includes public/private channels and direct/group conversations available to your user grant. Follow `response_metadata.next_cursor` with `--cursor` until it is empty; each call returns one page, and `--limit` accepts 1-200. The existing `list` command lists feed subscriptions, not Slack conversations.
@@ -87,7 +87,7 @@ subscriber's user grant, refuses to overwrite existing paths, and writes mode
87
87
  0600. External files without a Slack-hosted download are unsupported. A failed
88
88
  transfer may leave a partial output file; remove that file before retrying.
89
89
 
90
- `listen --resolve` adds `context.users` / `context.channels` name maps while preserving the original event and cursor. It fetches a complete user and conversation name snapshot in the background at startup and every six hours, caching the entire snapshot in memory until the next successful refresh. Failed refreshes keep the previous snapshot; unknown names fall back to IDs without blocking delivery. Restarting the listener fetches a fresh snapshot. Standalone file shares also get `context.files` metadata, fetched separately with a two-second deadline; failure leaves the original event intact and the files list empty. Use `file` or `download` to retry retrieving the file.
90
+ `listen` adds `context.users` / `context.channels` name maps while preserving the original event and cursor. It fetches a complete user and conversation name snapshot in the background at startup and every six hours, caching the entire snapshot in memory until the next successful refresh. Failed refreshes keep the previous snapshot; unknown names fall back to IDs without blocking delivery. Restarting the listener fetches a fresh snapshot. Standalone file shares also get `context.files` metadata, fetched separately with a two-second deadline; failure leaves the original event intact and the files list empty. Use `file` or `download` to retry retrieving the file.
91
91
  No read command changes the ACK cursor. The CLI uses its existing paired feed
92
92
  credential; Slack user tokens stay on the server. No bot credential is used.
93
93
 
package/dist/cli.js CHANGED
@@ -4,7 +4,7 @@ import { chmodSync, mkdirSync, readFileSync, writeFileSync, createWriteStream }
4
4
  import { homedir } from "node:os";
5
5
  import { dirname, join } from "node:path";
6
6
  export async function runSlackEventsCli(args) {
7
- const usage = `Usage: slack-events pair <server> [code] | listen [--resolve] | ack <committed-cursor> | list | revoke <subscription-id>
7
+ const usage = `Usage: slack-events pair <server> [code] | listen | ack <committed-cursor> | list | revoke <subscription-id>
8
8
  users [--limit N] [--cursor C] List users and their IDs
9
9
  channels [--limit N] [--cursor C] List conversations and their IDs
10
10
  user USER_ID Get user profile/name
@@ -100,9 +100,9 @@ Read commands print Slack JSON including pagination cursors. They never ACK even
100
100
  return;
101
101
  }
102
102
  if (command === "listen") {
103
- if (args.length > 2 || (args[1] && args[1] !== "--resolve"))
103
+ if (args.length !== 1)
104
104
  throw new Error(usage);
105
- await listen(credential, args[1] === "--resolve");
105
+ await listen(credential);
106
106
  return;
107
107
  }
108
108
  throw new Error(usage);
@@ -136,23 +136,18 @@ async function pairDevice(server) {
136
136
  }
137
137
  throw new Error("Pairing expired. Run the pairing command again for a new link.");
138
138
  }
139
- async function listen(credential, resolve = false) {
139
+ async function listen(credential) {
140
140
  const metadataAbort = new AbortController();
141
141
  const names = createNameResolver((operation, cursor) => request(credential.server, `/v1/events/slack/${operation}?${new URLSearchParams({ limit: "200", cursor })}`, { token: credential.token, signal: metadataAbort.signal }));
142
142
  const threadRoot = createThreadResolver((channel, ts) => request(credential.server, `/v1/events/slack/message?${new URLSearchParams({ id: channel, ts })}`, { token: credential.token, timeoutMs: 2_000, signal: metadataAbort.signal }));
143
143
  let after;
144
144
  try {
145
145
  for (;;) {
146
- if (resolve)
147
- void names.refresh();
146
+ void names.refresh();
148
147
  const path = `/v1/events?wait_ms=30000${after === undefined ? "" : `&after=${after}`}`;
149
148
  const response = await request(credential.server, path, { token: credential.token });
150
149
  const events = Array.isArray(response.events) ? response.events : [];
151
150
  for (const event of events) {
152
- if (!resolve) {
153
- await writeStdout(`${JSON.stringify(event)}\n`);
154
- continue;
155
- }
156
151
  const enriched = names.enrich(requireObject(event));
157
152
  const root = await threadRoot(requireObject(event));
158
153
  if (root) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zksecurity/slack-events",
3
- "version": "0.2.0",
3
+ "version": "0.2.1",
4
4
  "description": "Pair a terminal with a pi-mom Slack event feed",
5
5
  "type": "module",
6
6
  "bin": { "slack-events": "bin/slack-events.mjs" },
@@ -14,7 +14,7 @@ and user reauthorization before they work.
14
14
  ## Reading incoming events
15
15
 
16
16
  `listen` emits JSONL with `sequence`, stable `eventId`, `teamId`, `eventType`,
17
- `eventTime`, `receivedAt`, and the inner Slack `event`. `listen --resolve` adds
17
+ `eventTime`, `receivedAt`, and the inner Slack `event`. `listen` adds
18
18
  `context.users`, `context.channels`, and file metadata for `file_shared` events.
19
19
  For replies, optional `context.threadRoot` supplies the root timestamp, user,
20
20
  author name, and text. Root lookups have a two-second deadline and are cached;
@@ -95,7 +95,7 @@ use the authenticated CLI download rather than unauthenticated curl.
95
95
 
96
96
  ```sh
97
97
  slack-events pair https://YOUR-EVENT-HOST
98
- slack-events listen --resolve
98
+ slack-events listen
99
99
  slack-events list
100
100
  ```
101
101