@cuylabs/channel-slack 0.1.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.
Files changed (47) hide show
  1. package/LICENSE +201 -0
  2. package/README.md +168 -0
  3. package/dist/activity-ByrD9Ftr.d.ts +66 -0
  4. package/dist/assistant.d.ts +58 -0
  5. package/dist/assistant.js +188 -0
  6. package/dist/bolt.d.ts +344 -0
  7. package/dist/bolt.js +705 -0
  8. package/dist/chunk-BODPT4I6.js +322 -0
  9. package/dist/chunk-FPCE5V5Y.js +292 -0
  10. package/dist/chunk-FX2JOVX5.js +405 -0
  11. package/dist/chunk-JZG4IETE.js +141 -0
  12. package/dist/chunk-NE57BLLU.js +0 -0
  13. package/dist/chunk-TWJGVDA2.js +108 -0
  14. package/dist/core.d.ts +425 -0
  15. package/dist/core.js +42 -0
  16. package/dist/diagnostics.d.ts +105 -0
  17. package/dist/diagnostics.js +8 -0
  18. package/dist/feedback.d.ts +137 -0
  19. package/dist/feedback.js +128 -0
  20. package/dist/history.d.ts +266 -0
  21. package/dist/history.js +747 -0
  22. package/dist/index.d.ts +4 -0
  23. package/dist/index.js +57 -0
  24. package/dist/logging-Bl3HfcC8.d.ts +8 -0
  25. package/dist/policy.d.ts +130 -0
  26. package/dist/policy.js +16 -0
  27. package/dist/setup.d.ts +165 -0
  28. package/dist/setup.js +453 -0
  29. package/dist/shared.d.ts +2 -0
  30. package/dist/shared.js +43 -0
  31. package/dist/targets.d.ts +113 -0
  32. package/dist/targets.js +484 -0
  33. package/dist/users.d.ts +109 -0
  34. package/dist/users.js +240 -0
  35. package/docs/concepts/activity.md +33 -0
  36. package/docs/concepts/bolt-runtime.md +30 -0
  37. package/docs/concepts/message-policy.md +49 -0
  38. package/docs/concepts/setup-requirements.md +44 -0
  39. package/docs/concepts/supplemental-history.md +55 -0
  40. package/docs/recipes/app-mention-handler.md +34 -0
  41. package/docs/recipes/assistant-thread-handler.md +28 -0
  42. package/docs/recipes/generate-slack-manifest.md +28 -0
  43. package/docs/recipes/history-visibility.md +36 -0
  44. package/docs/recipes/socket-mode-app.md +29 -0
  45. package/docs/reference/channel-slack-boundary.md +50 -0
  46. package/docs/reference/exports.md +32 -0
  47. package/package.json +130 -0
package/dist/core.d.ts ADDED
@@ -0,0 +1,425 @@
1
+ import { S as SlackActivityInfo, b as SlackUserIdentity, a as SlackChannelType } from './activity-ByrD9Ftr.js';
2
+
3
+ /**
4
+ * Slack auth context — credentials and identifiers resolved from the inbound
5
+ * request. **Sensitive**: see security note on `SlackAuthContext`.
6
+ */
7
+ /**
8
+ * Slack credentials and identifiers resolved from the inbound request.
9
+ *
10
+ * Surfaced to `prepareTurn`, the ambient `currentSlackTurnContext()`, and the
11
+ * assistant message context so tools and middleware can call the Slack Web
12
+ * API or attach per-user OAuth tokens to MCP servers (see
13
+ * `createSlackMcpServerConfig`).
14
+ *
15
+ * Security: `botToken` and `userToken` are secrets. Do not include this auth
16
+ * bag in logs, telemetry attributes, baggage, tool results, message history,
17
+ * or model-visible prompts. Pass only the exact token needed to a trusted
18
+ * Slack API/MCP client.
19
+ *
20
+ * Most fields come from Bolt's enriched `args.context`. They are all optional
21
+ * because availability depends on the auth mode (single-workspace vs OAuth)
22
+ * and on whether the installer granted user scopes.
23
+ */
24
+ interface SlackAuthContext {
25
+ /** Workspace bot token (`xoxb-...`). */
26
+ botToken?: string;
27
+ /** End-user OAuth token (`xoxp-...`) when user scopes were granted. */
28
+ userToken?: string;
29
+ /** Workspace ID (`T...`). */
30
+ teamId?: string;
31
+ /** Enterprise grid ID (`E...`) when applicable. */
32
+ enterpriseId?: string;
33
+ /** Bot user ID (`U...`) — useful for distinguishing bot self-mentions. */
34
+ botUserId?: string;
35
+ /** Internal Slack bot ID (`B...`). */
36
+ botId?: string;
37
+ /** Slack user ID (`U...`) of the human author of the inbound event. */
38
+ userId?: string;
39
+ }
40
+
41
+ /**
42
+ * Slack assistant lifecycle types — status updates, suggested prompts, thread
43
+ * context, and the channel-neutral `SlackAssistantUtilities` interface that
44
+ * the assistant bridge surfaces ambiently for tools and middleware.
45
+ */
46
+ /**
47
+ * Slack assistant thread context — the channel of origin metadata Slack tracks
48
+ * while a user navigates the workspace. Surfaces the same fields Bolt's
49
+ * `AssistantThreadContextStore` returns.
50
+ *
51
+ * @see https://docs.slack.dev/reference/events/assistant_thread_context_changed
52
+ */
53
+ interface SlackAssistantThreadContext {
54
+ channel_id?: string;
55
+ team_id?: string;
56
+ enterprise_id?: string | null;
57
+ }
58
+ /** Display mode passed to `client.chatStream`. */
59
+ type SlackAssistantTaskDisplayMode = "plan" | "timeline";
60
+ /**
61
+ * Slack message authorship fields supported by AI assistant status updates
62
+ * and native chat stream start calls.
63
+ */
64
+ interface SlackMessageAuthorshipOptions {
65
+ /** Emoji shown as the message/status icon, e.g. `":robot_face:"`. */
66
+ icon_emoji?: string;
67
+ /** Image URL shown as the message/status icon. */
68
+ icon_url?: string;
69
+ /** Display name shown for the message/status. */
70
+ username?: string;
71
+ }
72
+ /** Optional passthrough fields for Slack's native `chat.startStream`. */
73
+ type SlackChatStreamStartArgs = SlackMessageAuthorshipOptions & {
74
+ /**
75
+ * Slack task display mode for streamed tool/task chunks. `timeline` shows
76
+ * individual task cards; `plan` groups task cards together.
77
+ */
78
+ task_display_mode?: SlackAssistantTaskDisplayMode;
79
+ };
80
+ /** A single suggested prompt chip shown in the assistant pane. */
81
+ interface SlackAssistantSuggestedPrompt {
82
+ title: string;
83
+ message: string;
84
+ }
85
+ /** Suggested prompts payload for `assistant.threads.setSuggestedPrompts`. */
86
+ interface SlackAssistantSuggestedPrompts {
87
+ /** Title shown above the chips. Defaults to Slack's "Try these prompts:". */
88
+ title?: string;
89
+ prompts: SlackAssistantSuggestedPrompt[];
90
+ }
91
+ /** Status payload accepted by Bolt's assistant `setStatus`. */
92
+ interface SlackAssistantStatusUpdate extends SlackMessageAuthorshipOptions {
93
+ status: string;
94
+ loading_messages?: string[];
95
+ }
96
+ /**
97
+ * Assistant pane utilities surfaced ambiently so tools/middleware can call
98
+ * them mid-turn without wiring the raw Bolt args through.
99
+ *
100
+ * Only present when the turn is running through the assistant bridge.
101
+ */
102
+ interface SlackAssistantUtilities {
103
+ setStatus: (update: SlackAssistantStatusUpdate) => Promise<void>;
104
+ setSuggestedPrompts: (prompts: SlackAssistantSuggestedPrompts) => Promise<void>;
105
+ setTitle: (title: string) => Promise<void>;
106
+ getThreadContext: () => Promise<SlackAssistantThreadContext>;
107
+ saveThreadContext: () => Promise<void>;
108
+ }
109
+ /**
110
+ * Status utility exposed by Bolt for any message/app_mention event with a
111
+ * channel + thread timestamp. It calls Slack's assistant thread status API,
112
+ * but unlike the full Assistant surface it does not imply suggested prompts,
113
+ * thread titles, or origin-channel context.
114
+ */
115
+ type SlackThreadStatusSetter = (update: SlackAssistantStatusUpdate) => Promise<void>;
116
+
117
+ /**
118
+ * Slack turn-request and turn-preparation contracts shared by Slack transport
119
+ * packages. Direct Slack fills these from Bolt events; M365-backed Slack fills
120
+ * the same shape from Bot Framework activities.
121
+ */
122
+
123
+ /**
124
+ * Context available while preparing a Slack turn.
125
+ */
126
+ interface SlackTurnRequestContext {
127
+ /** Parsed Slack activity metadata */
128
+ slackActivity: SlackActivityInfo;
129
+ /** Extracted Slack user identity */
130
+ user: SlackUserIdentity;
131
+ /** Resolved agent session ID for this conversation */
132
+ sessionId: string;
133
+ /** Plain-text message forwarded to the host application */
134
+ message: string;
135
+ /**
136
+ * Slack auth + identity resolved from the inbound request.
137
+ *
138
+ * Includes the bot token, optional end-user OAuth token, team/enterprise
139
+ * IDs, and bot user ID. Tools and `prepareTurn` callers can use these to
140
+ * call the Slack Web API or attach the user token to MCP servers.
141
+ */
142
+ auth?: SlackAuthContext;
143
+ /**
144
+ * Assistant thread context resolved by Bolt for assistant-pane turns.
145
+ *
146
+ * Tells the agent which channel/workspace the user is currently viewing
147
+ * while talking to the assistant — useful for context-aware system prompts
148
+ * and for resolving relative references like "this channel".
149
+ *
150
+ * `undefined` when the turn was not routed through the assistant bridge.
151
+ */
152
+ threadContext?: SlackAssistantThreadContext;
153
+ /**
154
+ * Slack thread status setter available when Bolt provides `setStatus` for
155
+ * the inbound event. This can be present on classic `app_mention` /
156
+ * `message` turns as well as full Assistant-pane turns.
157
+ */
158
+ setStatus?: SlackThreadStatusSetter;
159
+ }
160
+ /**
161
+ * Optional turn preparation result for a Slack turn.
162
+ */
163
+ interface SlackTurnPreparation {
164
+ /** Optional system override for the host application */
165
+ system?: string;
166
+ /** Optional message override for the host application. */
167
+ message?: string;
168
+ /** Optional session override for this turn. */
169
+ sessionId?: string;
170
+ /** Optional custom scope name for the activity */
171
+ scopeName?: string;
172
+ /** Additional scalar attributes merged into the activity scope */
173
+ scopeAttributes?: Record<string, string | number | boolean | null | undefined>;
174
+ /** Arbitrary app-specific per-turn context exposed via AsyncLocalStorage */
175
+ context?: Record<string, unknown>;
176
+ }
177
+
178
+ /**
179
+ * Transport-neutral interactive request contracts.
180
+ *
181
+ * These types let callers delegate approval and human-input requests to a
182
+ * Slack-specific renderer without importing Bolt or Web API types into
183
+ * `shared/`.
184
+ */
185
+
186
+ type SlackInteractiveRequestKind = "approval" | "human-input";
187
+ type SlackApprovalRequest = Record<string, unknown>;
188
+ type SlackHumanInputRequest = Record<string, unknown>;
189
+ type SlackInteractiveRequest = SlackApprovalRequest | SlackHumanInputRequest;
190
+ interface SlackInteractiveMessageRef {
191
+ channel: string;
192
+ ts: string;
193
+ }
194
+ interface SlackInteractiveMessage {
195
+ text: string;
196
+ blocks?: unknown[];
197
+ }
198
+ interface SlackInteractiveResponder {
199
+ postMessage(message: SlackInteractiveMessage): Promise<SlackInteractiveMessageRef>;
200
+ updateMessage(ref: SlackInteractiveMessageRef, message: SlackInteractiveMessage): Promise<void>;
201
+ }
202
+ interface SlackInteractiveRequestBaseContext {
203
+ kind: SlackInteractiveRequestKind;
204
+ request: SlackInteractiveRequest;
205
+ fallbackText: string;
206
+ }
207
+ interface SlackInteractiveRequestContext extends SlackInteractiveRequestBaseContext {
208
+ slackActivity: SlackActivityInfo;
209
+ user: SlackUserIdentity;
210
+ sessionId: string;
211
+ message: string;
212
+ responder: SlackInteractiveResponder;
213
+ }
214
+ type SlackInteractiveRequestHandler = (context: SlackInteractiveRequestContext) => boolean | void | Promise<boolean | void>;
215
+ type SlackEventInteractiveRequestHandler = (context: SlackInteractiveRequestBaseContext) => boolean | void | Promise<boolean | void>;
216
+
217
+ /**
218
+ * Raw Slack event payload parsers — produce `SlackActivityInfo` from the
219
+ * shapes Bolt delivers for `message` and `app_mention` events.
220
+ */
221
+
222
+ interface RawSlackAssistantThreadPayload {
223
+ action_token?: string;
224
+ [key: string]: unknown;
225
+ }
226
+ interface RawSlackActionTokenPayload {
227
+ action_token?: unknown;
228
+ assistant_thread?: unknown;
229
+ }
230
+ interface RawSlackMessagePayload {
231
+ type: string;
232
+ subtype?: string;
233
+ text?: string;
234
+ user?: string;
235
+ bot_id?: string;
236
+ channel?: string;
237
+ channel_type?: string;
238
+ ts?: string;
239
+ thread_ts?: string;
240
+ parent_user_id?: string;
241
+ team?: string;
242
+ action_token?: string;
243
+ assistant_thread?: RawSlackAssistantThreadPayload;
244
+ blocks?: unknown[];
245
+ attachments?: unknown[];
246
+ }
247
+ interface RawSlackAppMentionPayload {
248
+ type: string;
249
+ text?: string;
250
+ user?: string;
251
+ channel?: string;
252
+ ts?: string;
253
+ thread_ts?: string;
254
+ parent_user_id?: string;
255
+ team?: string;
256
+ action_token?: string;
257
+ assistant_thread?: RawSlackAssistantThreadPayload;
258
+ blocks?: unknown[];
259
+ attachments?: unknown[];
260
+ }
261
+ declare function extractSlackActionToken(payload: RawSlackActionTokenPayload | undefined): string | undefined;
262
+ /**
263
+ * Parse a raw Slack message event payload into a `SlackActivityInfo`.
264
+ */
265
+ declare function parseSlackMessageActivity(payload: RawSlackMessagePayload): SlackActivityInfo;
266
+ /**
267
+ * Parse a raw Slack `app_mention` event payload into a `SlackActivityInfo`.
268
+ */
269
+ declare function parseSlackMentionActivity(payload: RawSlackAppMentionPayload): SlackActivityInfo;
270
+
271
+ /**
272
+ * Slack channel-type classification + message-text normalisation helpers.
273
+ */
274
+
275
+ /**
276
+ * Classify a Slack channel ID into a high-level surface type.
277
+ *
278
+ * Slack channel IDs have stable prefixes:
279
+ * - `D` — Direct message (IM)
280
+ * - `C` — Public or private channel
281
+ * - `G` — Multi-party DM / group DM (legacy)
282
+ */
283
+ declare function resolveSlackChannelType(channelId: string, threadTs: string | undefined, inReplyToMessage: boolean): SlackChannelType;
284
+ /**
285
+ * Strip leading `<@USERID>` mention(s) from a Slack message text.
286
+ * Slack wraps mentions in `<@U...>` format in the raw message text.
287
+ */
288
+ declare function stripLeadingMentions(text: string): string;
289
+ /**
290
+ * Return `true` if a raw Slack message payload represents a plain user
291
+ * message that the adapter should process. Filters out bot messages,
292
+ * edits, deletions, and other system subtypes.
293
+ */
294
+ declare function isProcessableMessage(payload: RawSlackMessagePayload): boolean;
295
+
296
+ interface ExtractSlackMessageTextOptions {
297
+ /**
298
+ * Strip leading Slack mention tokens from the final extracted text.
299
+ *
300
+ * Useful for `app_mention` and non-DM message handling where the leading bot
301
+ * mention should not become model input.
302
+ */
303
+ stripLeadingMentions?: boolean;
304
+ }
305
+ interface SlackMessageTextPayload {
306
+ text?: string;
307
+ blocks?: unknown[];
308
+ attachments?: unknown[];
309
+ }
310
+ /**
311
+ * Extract model-facing text from a Slack message payload.
312
+ *
313
+ * Slack often includes useful user-visible text in Block Kit payloads even
314
+ * when `payload.text` is missing or too generic. This helper keeps the common
315
+ * fast path (`text`) but falls back to rich text, section/header/context text,
316
+ * image/video alt/title text, and legacy Slack attachment fields when needed.
317
+ */
318
+ declare function extractSlackMessageText(payload: SlackMessageTextPayload | undefined, options?: ExtractSlackMessageTextOptions): string;
319
+ declare function extractSlackBlocksText(blocks: unknown): string;
320
+ declare function extractSlackAttachmentsText(attachments: unknown): string;
321
+
322
+ /**
323
+ * Identity + auth extractors that sit alongside the Slack activity parsers.
324
+ *
325
+ * `extractSlackAuthContext` reads Bolt's enriched `args.context` bag and
326
+ * returns the credentials needed for outgoing Slack API calls. The result is
327
+ * sensitive — see the security note on `SlackAuthContext`.
328
+ */
329
+
330
+ /**
331
+ * Extract a `SlackUserIdentity` from a parsed `SlackActivityInfo`.
332
+ */
333
+ declare function extractSlackUserIdentity(info: SlackActivityInfo): SlackUserIdentity;
334
+ /**
335
+ * Extract Slack auth and identity values from Bolt's enriched `context` bag.
336
+ *
337
+ * The returned object can contain bot/user OAuth tokens. Treat it as
338
+ * sensitive: keep it in ambient turn context only and never copy it into
339
+ * logs, telemetry attributes, or model-visible content.
340
+ */
341
+ declare function extractSlackAuthContext(context: unknown, eventUserId?: string): SlackAuthContext;
342
+
343
+ /**
344
+ * Slack text formatting helpers.
345
+ *
346
+ * Agent models generally emit CommonMark-style markdown. Slack accepts its
347
+ * own mrkdwn dialect, so direct Slack and Slack-via-ABS transports should
348
+ * normalize common constructs before posting.
349
+ */
350
+ type SlackMessageFormatter = (text: string) => string;
351
+ interface SlackMessageFormattingOptions {
352
+ /**
353
+ * Convert common markdown constructs to Slack mrkdwn.
354
+ *
355
+ * @default true
356
+ */
357
+ formatChatMarkdown?: boolean;
358
+ /**
359
+ * Custom text formatter. When provided, this takes precedence over the
360
+ * built-in markdown-to-mrkdwn conversion.
361
+ */
362
+ formatMessageText?: SlackMessageFormatter;
363
+ }
364
+ declare function resolveSlackMessageFormatter(options: SlackMessageFormattingOptions): SlackMessageFormatter;
365
+ declare function markdownToSlackMrkdwn(markdown: string): string;
366
+
367
+ declare function formatSlackAttributedFollowUp(message: string): string;
368
+
369
+ /**
370
+ * Resolve Slack sessions using natural Slack conversation boundaries.
371
+ *
372
+ * - DMs use the channel ID.
373
+ * - Thread replies use `channelId:threadTs`.
374
+ * - Top-level channel messages use `channelId:messageTs`, so follow-up
375
+ * replies in the created thread can share context.
376
+ */
377
+ declare function resolveThreadAwareSlackSessionId(info: SlackActivityInfo): string;
378
+
379
+ /**
380
+ * Ambient turn context exposed via `currentSlackTurnContext()`.
381
+ *
382
+ * Tools and middleware running inside a Slack turn can read this to call the
383
+ * Slack Web API, attach the per-user OAuth token to MCP servers, or update
384
+ * the assistant pane (status, suggested prompts, title) mid-turn.
385
+ *
386
+ * Security: `auth.botToken` and `auth.userToken` are secrets. Do not write
387
+ * them to logs, traces, telemetry baggage, tool results, message history, or
388
+ * model-visible prompts. Pass only the exact token needed to trusted Slack
389
+ * clients or MCP transports.
390
+ *
391
+ * Fields beyond `SlackTurnRequestContext`:
392
+ * - `context` — arbitrary host-supplied bag from `prepareTurn`
393
+ * - `assistant` — assistant pane utilities (only present on assistant turns)
394
+ *
395
+ * The auth bag, `threadContext`, and generic `setStatus` status setter are
396
+ * inherited from `SlackTurnRequestContext`.
397
+ */
398
+ interface SlackAmbientTurnContext extends SlackTurnRequestContext {
399
+ /**
400
+ * Arbitrary app-specific turn context resolved by `prepareTurn(...)`.
401
+ *
402
+ * Use this for things like user preferences, workspace-scoped config, or
403
+ * request-bound helper objects needed by tools and middleware.
404
+ */
405
+ context?: Record<string, unknown>;
406
+ /**
407
+ * Assistant pane utilities (`setStatus`, `setSuggestedPrompts`, `setTitle`,
408
+ * `getThreadContext`, `saveThreadContext`).
409
+ *
410
+ * Only present when the turn is routed through the assistant bridge. Use the
411
+ * top-level `setStatus` when code only needs status updates and should also
412
+ * work for classic `app_mention` / `message` turns.
413
+ */
414
+ assistant?: SlackAssistantUtilities;
415
+ }
416
+ /**
417
+ * Return the Slack turn currently bound to this async execution context.
418
+ *
419
+ * The returned context can contain Slack OAuth tokens in `auth`; treat it as
420
+ * sensitive application state and never serialize it wholesale.
421
+ */
422
+ declare function currentSlackTurnContext(): Readonly<SlackAmbientTurnContext> | undefined;
423
+ declare function runWithSlackTurnContext<T>(value: SlackAmbientTurnContext, fn: () => T | Promise<T>): Promise<T>;
424
+
425
+ export { type ExtractSlackMessageTextOptions, type RawSlackActionTokenPayload, type RawSlackAppMentionPayload, type RawSlackAssistantThreadPayload, type RawSlackMessagePayload, SlackActivityInfo, type SlackAmbientTurnContext, type SlackApprovalRequest, type SlackAssistantStatusUpdate, type SlackAssistantSuggestedPrompt, type SlackAssistantSuggestedPrompts, type SlackAssistantTaskDisplayMode, type SlackAssistantThreadContext, type SlackAssistantUtilities, type SlackAuthContext, SlackChannelType, type SlackChatStreamStartArgs, type SlackEventInteractiveRequestHandler, type SlackHumanInputRequest, type SlackInteractiveMessage, type SlackInteractiveMessageRef, type SlackInteractiveRequest, type SlackInteractiveRequestBaseContext, type SlackInteractiveRequestContext, type SlackInteractiveRequestHandler, type SlackInteractiveRequestKind, type SlackInteractiveResponder, type SlackMessageAuthorshipOptions, type SlackMessageFormatter, type SlackMessageFormattingOptions, type SlackMessageTextPayload, type SlackThreadStatusSetter, type SlackTurnPreparation, type SlackTurnRequestContext, SlackUserIdentity, currentSlackTurnContext, extractSlackActionToken, extractSlackAttachmentsText, extractSlackAuthContext, extractSlackBlocksText, extractSlackMessageText, extractSlackUserIdentity, formatSlackAttributedFollowUp, isProcessableMessage, markdownToSlackMrkdwn, parseSlackMentionActivity, parseSlackMessageActivity, resolveSlackChannelType, resolveSlackMessageFormatter, resolveThreadAwareSlackSessionId, runWithSlackTurnContext, stripLeadingMentions };
package/dist/core.js ADDED
@@ -0,0 +1,42 @@
1
+ import {
2
+ currentSlackTurnContext,
3
+ formatSlackAttributedFollowUp,
4
+ markdownToSlackMrkdwn,
5
+ resolveSlackMessageFormatter,
6
+ resolveThreadAwareSlackSessionId,
7
+ runWithSlackTurnContext
8
+ } from "./chunk-JZG4IETE.js";
9
+ import {
10
+ extractSlackActionToken,
11
+ extractSlackAuthContext,
12
+ extractSlackUserIdentity,
13
+ parseSlackMentionActivity,
14
+ parseSlackMessageActivity
15
+ } from "./chunk-TWJGVDA2.js";
16
+ import {
17
+ extractSlackAttachmentsText,
18
+ extractSlackBlocksText,
19
+ extractSlackMessageText,
20
+ isProcessableMessage,
21
+ resolveSlackChannelType,
22
+ stripLeadingMentions
23
+ } from "./chunk-FPCE5V5Y.js";
24
+ export {
25
+ currentSlackTurnContext,
26
+ extractSlackActionToken,
27
+ extractSlackAttachmentsText,
28
+ extractSlackAuthContext,
29
+ extractSlackBlocksText,
30
+ extractSlackMessageText,
31
+ extractSlackUserIdentity,
32
+ formatSlackAttributedFollowUp,
33
+ isProcessableMessage,
34
+ markdownToSlackMrkdwn,
35
+ parseSlackMentionActivity,
36
+ parseSlackMessageActivity,
37
+ resolveSlackChannelType,
38
+ resolveSlackMessageFormatter,
39
+ resolveThreadAwareSlackSessionId,
40
+ runWithSlackTurnContext,
41
+ stripLeadingMentions
42
+ };
@@ -0,0 +1,105 @@
1
+ type SlackScopeInspectionMethod = "auth.test" | "auth.scopes" | "apps.permissions.info";
2
+ type SlackConnectionInspectionFindingSeverity = "info" | "warning" | "error";
3
+ type SlackTokenSource = "provided" | "environment" | "client" | "none";
4
+ interface SlackDiagnosticsClient {
5
+ auth: {
6
+ test(args?: {
7
+ token?: string;
8
+ }): Promise<unknown>;
9
+ };
10
+ apiCall(method: string, args?: Record<string, unknown>): Promise<unknown>;
11
+ }
12
+ interface SlackApiInspectionError {
13
+ message: string;
14
+ code?: string;
15
+ method?: string;
16
+ needed?: string;
17
+ providedScopes?: string[];
18
+ acceptedScopes?: string[];
19
+ statusCode?: number;
20
+ }
21
+ interface SlackScopeInspectionMethodError {
22
+ method: SlackScopeInspectionMethod;
23
+ error: SlackApiInspectionError;
24
+ }
25
+ interface SlackScopeInspection {
26
+ ok: boolean;
27
+ scopes: string[];
28
+ source?: SlackScopeInspectionMethod;
29
+ errors: SlackScopeInspectionMethodError[];
30
+ }
31
+ interface SlackConnectionInspectionFinding {
32
+ severity: SlackConnectionInspectionFindingSeverity;
33
+ code: string;
34
+ message: string;
35
+ }
36
+ interface SlackConnectionAuthInfo {
37
+ ok: boolean;
38
+ url?: string;
39
+ team?: string;
40
+ teamId?: string;
41
+ user?: string;
42
+ userId?: string;
43
+ botId?: string;
44
+ enterpriseId?: string;
45
+ isEnterpriseInstall?: boolean;
46
+ }
47
+ interface SlackConnectionInspection {
48
+ ok: boolean;
49
+ tokenSource: SlackTokenSource;
50
+ elapsedMs: number;
51
+ auth?: SlackConnectionAuthInfo;
52
+ scopes?: SlackScopeInspection;
53
+ requiredScopes: string[];
54
+ optionalScopes: string[];
55
+ missingRequiredScopes: string[];
56
+ missingOptionalScopes: string[];
57
+ findings: SlackConnectionInspectionFinding[];
58
+ error?: SlackApiInspectionError;
59
+ }
60
+ interface InspectSlackTokenScopesOptions {
61
+ /**
62
+ * Slack bot or user OAuth token. When omitted, the injected client is used
63
+ * as-is and no token override is passed to Slack API calls.
64
+ */
65
+ token?: string;
66
+ /** Inject a preconfigured Slack Web API client, useful for OAuth stores/tests. */
67
+ client?: SlackDiagnosticsClient;
68
+ /**
69
+ * Maximum time for each Slack API request in milliseconds. Set `0` to
70
+ * disable the local timeout wrapper.
71
+ *
72
+ * @default 2500
73
+ */
74
+ requestTimeoutMs?: number;
75
+ /**
76
+ * Scope-bearing methods to try in order.
77
+ *
78
+ * @default ["auth.test", "auth.scopes", "apps.permissions.info"]
79
+ */
80
+ methods?: readonly SlackScopeInspectionMethod[];
81
+ }
82
+ interface InspectSlackConnectionOptions extends Omit<InspectSlackTokenScopesOptions, "methods"> {
83
+ /**
84
+ * Slack OAuth scopes that must be present for this installation to be
85
+ * considered usable by the caller.
86
+ */
87
+ requiredScopes?: readonly string[];
88
+ /**
89
+ * Slack OAuth scopes that are useful but not mandatory. Missing optional
90
+ * scopes are returned as warnings.
91
+ */
92
+ optionalScopes?: readonly string[];
93
+ /**
94
+ * Whether to inspect token scopes after `auth.test` succeeds.
95
+ *
96
+ * @default true
97
+ */
98
+ inspectScopes?: boolean;
99
+ /** Override the scope-inspection method order. */
100
+ scopeMethods?: readonly SlackScopeInspectionMethod[];
101
+ }
102
+ declare function inspectSlackConnection(options?: InspectSlackConnectionOptions): Promise<SlackConnectionInspection>;
103
+ declare function inspectSlackTokenScopes(options?: InspectSlackTokenScopesOptions): Promise<SlackScopeInspection>;
104
+
105
+ export { type InspectSlackConnectionOptions, type InspectSlackTokenScopesOptions, type SlackApiInspectionError, type SlackConnectionInspection, type SlackConnectionInspectionFinding, type SlackConnectionInspectionFindingSeverity, type SlackDiagnosticsClient, type SlackScopeInspection, type SlackScopeInspectionMethod, type SlackScopeInspectionMethodError, type SlackTokenSource, inspectSlackConnection, inspectSlackTokenScopes };
@@ -0,0 +1,8 @@
1
+ import {
2
+ inspectSlackConnection,
3
+ inspectSlackTokenScopes
4
+ } from "./chunk-FX2JOVX5.js";
5
+ export {
6
+ inspectSlackConnection,
7
+ inspectSlackTokenScopes
8
+ };