@cuylabs/channel-slack 0.5.1 → 0.6.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 (62) hide show
  1. package/README.md +25 -136
  2. package/dist/app-home.d.ts +23 -0
  3. package/dist/app-home.js +35 -0
  4. package/dist/artifacts/index.d.ts +135 -0
  5. package/dist/artifacts/index.js +299 -0
  6. package/dist/{assistant.d.ts → assistant/index.d.ts} +1 -1
  7. package/dist/{assistant.js → assistant/index.js} +2 -2
  8. package/dist/auth/index.d.ts +56 -0
  9. package/dist/auth/index.js +168 -0
  10. package/dist/{chunk-IDVDMJ5U.js → chunk-6JSGIVQH.js} +110 -3
  11. package/dist/chunk-6WHFQUYQ.js +54 -0
  12. package/dist/{bolt.js → chunk-73QXT7MA.js} +25 -320
  13. package/dist/{chunk-CMR6B76C.js → chunk-DNVSH7H5.js} +407 -1
  14. package/dist/chunk-QJYCHWN6.js +76 -0
  15. package/dist/chunk-S3SWPYXJ.js +81 -0
  16. package/dist/{chunk-JZG4IETE.js → chunk-X4WBBBYM.js} +0 -52
  17. package/dist/core.js +5 -3
  18. package/dist/diagnostics/index.d.ts +71 -0
  19. package/dist/{diagnostics.js → diagnostics/index.js} +5 -1
  20. package/dist/entrypoints/index.d.ts +120 -0
  21. package/dist/entrypoints/index.js +132 -0
  22. package/dist/{history.d.ts → history/index.d.ts} +2 -2
  23. package/dist/{history.js → history/index.js} +1 -1
  24. package/dist/index.d.ts +1 -1
  25. package/dist/index.js +28 -15
  26. package/dist/{policy.d.ts → policy/index.d.ts} +103 -2
  27. package/dist/{policy.js → policy/index.js} +13 -1
  28. package/dist/runtime-BNBHOZSQ.d.ts +53 -0
  29. package/dist/{setup.d.ts → setup/index.d.ts} +30 -3
  30. package/dist/{setup.js → setup/index.js} +134 -3
  31. package/dist/transports/http/index.d.ts +68 -0
  32. package/dist/transports/http/index.js +8 -0
  33. package/dist/transports/index.d.ts +8 -0
  34. package/dist/transports/index.js +24 -0
  35. package/dist/transports/socket/index.d.ts +94 -0
  36. package/dist/transports/socket/index.js +19 -0
  37. package/dist/types-B9NfCVrk.d.ts +141 -0
  38. package/docs/README.md +31 -0
  39. package/docs/concepts/activity.md +3 -3
  40. package/docs/concepts/artifacts.md +56 -0
  41. package/docs/concepts/entrypoints.md +73 -0
  42. package/docs/concepts/setup-requirements.md +23 -0
  43. package/docs/concepts/{bolt-runtime.md → transport-runtime.md} +9 -4
  44. package/docs/recipes/generate-slack-manifest.md +16 -0
  45. package/docs/recipes/publish-artifact.md +45 -0
  46. package/docs/recipes/slash-command-and-shortcut.md +51 -0
  47. package/docs/recipes/socket-mode-app.md +1 -1
  48. package/docs/reference/channel-slack-boundary.md +10 -6
  49. package/docs/reference/exports.md +7 -2
  50. package/docs/reference/source-layout.md +35 -0
  51. package/package.json +63 -39
  52. package/dist/bolt.d.ts +0 -364
  53. package/dist/chunk-NE57BLLU.js +0 -0
  54. package/dist/diagnostics.d.ts +0 -22
  55. package/dist/shared.d.ts +0 -2
  56. package/dist/shared.js +0 -43
  57. /package/dist/{feedback.d.ts → feedback/index.d.ts} +0 -0
  58. /package/dist/{feedback.js → feedback/index.js} +0 -0
  59. /package/dist/{targets.d.ts → targets/index.d.ts} +0 -0
  60. /package/dist/{targets.js → targets/index.js} +0 -0
  61. /package/dist/{users.d.ts → users/index.d.ts} +0 -0
  62. /package/dist/{users.js → users/index.js} +0 -0
@@ -0,0 +1,71 @@
1
+ import { g as SlackIdentityExpectations, b as SlackAuthTestIdentity } from '../inspect-BpY5JA0K.js';
2
+ export { I as InspectSlackConnectionOptions, a as InspectSlackTokenScopesOptions, S as SlackApiInspectionError, c as SlackConnectionInspection, d as SlackConnectionInspectionFinding, e as SlackConnectionInspectionFindingSeverity, f as SlackDiagnosticsClient, h as SlackIdentityMismatch, i as SlackScopeInspection, j as SlackScopeInspectionMethod, k as SlackScopeInspectionMethodError, l as SlackTokenSource, m as compareSlackIdentity, n as formatSlackIdentityMismatches, o as inspectSlackConnection, p as inspectSlackTokenScopes, q as normalizeSlackAuthTestIdentity } from '../inspect-BpY5JA0K.js';
3
+ import { d as SlackSocketModeRuntimePolicy } from '../runtime-BNBHOZSQ.js';
4
+ import '@slack/bolt';
5
+ import '../logging-Bl3HfcC8.js';
6
+
7
+ interface SlackPayloadDebugSummary {
8
+ rawArgs: unknown;
9
+ rawArgsActionTokenPaths: string[];
10
+ rawArgsKeyPaths: string[];
11
+ rawArgsTokenLikePaths: string[];
12
+ slackActivity: unknown;
13
+ threadContext: unknown;
14
+ }
15
+ declare function summarizeSlackPayloadDebug({ rawArgs, slackActivity, threadContext, }: {
16
+ rawArgs?: unknown;
17
+ slackActivity: unknown;
18
+ threadContext: unknown;
19
+ }): SlackPayloadDebugSummary;
20
+ declare function selectSlackRawArgsForDebug(rawArgs: unknown): unknown;
21
+ declare function selectSlackBodyForDebug(body: unknown): unknown;
22
+ declare function redactSlackDebugValue(value: unknown, depth?: number): unknown;
23
+ declare function collectJsonKeyPaths(value: unknown): string[];
24
+ declare function findJsonKeyPaths(value: unknown, predicate: (key: string) => boolean): string[];
25
+
26
+ type SlackStartupReadinessTransport = "http" | "socket";
27
+ interface SlackStartupReadinessConfig extends SlackIdentityExpectations {
28
+ authMode: "single-workspace" | string;
29
+ botToken?: string;
30
+ enabled: boolean;
31
+ socketModeRuntimePolicy?: SlackSocketModeRuntimePolicy;
32
+ transport: SlackStartupReadinessTransport;
33
+ }
34
+ interface SlackStartupReadinessOptions {
35
+ clientFactory?: (botToken: string) => SlackStartupAuthTestClient;
36
+ config: SlackStartupReadinessConfig;
37
+ logger?: SlackStartupReadinessLogger;
38
+ }
39
+ interface SlackStartupReadinessResult {
40
+ authMode: string;
41
+ identity?: SlackAuthTestIdentity;
42
+ identityCheck: "disabled" | "passed" | "skipped";
43
+ socketModeRuntimePolicy?: SlackSocketModeRuntimePolicy;
44
+ transport: SlackStartupReadinessTransport;
45
+ }
46
+ interface SlackStartupAuthTestClient {
47
+ auth: {
48
+ test(): Promise<SlackStartupAuthTestResponse>;
49
+ };
50
+ }
51
+ interface SlackStartupAuthTestResponse {
52
+ bot_id?: string;
53
+ error?: string;
54
+ ok?: boolean;
55
+ team?: string;
56
+ team_id?: string;
57
+ url?: string;
58
+ user_id?: string;
59
+ }
60
+ interface SlackStartupReadinessLogger {
61
+ debug?(message: string, attributes?: Record<string, unknown>): void;
62
+ info?(message: string, attributes?: Record<string, unknown>): void;
63
+ warn?(message: string, attributes?: Record<string, unknown>): void;
64
+ }
65
+ declare class SlackStartupReadinessError extends Error {
66
+ readonly issues: readonly string[];
67
+ constructor(issues: readonly string[]);
68
+ }
69
+ declare function runSlackStartupReadiness({ clientFactory, config, logger, }: SlackStartupReadinessOptions): Promise<SlackStartupReadinessResult>;
70
+
71
+ export { SlackAuthTestIdentity, SlackIdentityExpectations, type SlackPayloadDebugSummary, type SlackStartupAuthTestClient, type SlackStartupAuthTestResponse, type SlackStartupReadinessConfig, SlackStartupReadinessError, type SlackStartupReadinessLogger, type SlackStartupReadinessOptions, type SlackStartupReadinessResult, type SlackStartupReadinessTransport, collectJsonKeyPaths, findJsonKeyPaths, redactSlackDebugValue, runSlackStartupReadiness, selectSlackBodyForDebug, selectSlackRawArgsForDebug, summarizeSlackPayloadDebug };
@@ -1,4 +1,5 @@
1
1
  import {
2
+ SlackStartupReadinessError,
2
3
  collectJsonKeyPaths,
3
4
  compareSlackIdentity,
4
5
  findJsonKeyPaths,
@@ -7,11 +8,13 @@ import {
7
8
  inspectSlackTokenScopes,
8
9
  normalizeSlackAuthTestIdentity,
9
10
  redactSlackDebugValue,
11
+ runSlackStartupReadiness,
10
12
  selectSlackBodyForDebug,
11
13
  selectSlackRawArgsForDebug,
12
14
  summarizeSlackPayloadDebug
13
- } from "./chunk-IDVDMJ5U.js";
15
+ } from "../chunk-6JSGIVQH.js";
14
16
  export {
17
+ SlackStartupReadinessError,
15
18
  collectJsonKeyPaths,
16
19
  compareSlackIdentity,
17
20
  findJsonKeyPaths,
@@ -20,6 +23,7 @@ export {
20
23
  inspectSlackTokenScopes,
21
24
  normalizeSlackAuthTestIdentity,
22
25
  redactSlackDebugValue,
26
+ runSlackStartupReadiness,
23
27
  selectSlackBodyForDebug,
24
28
  selectSlackRawArgsForDebug,
25
29
  summarizeSlackPayloadDebug
@@ -0,0 +1,120 @@
1
+ import { S as SlackActivityInfo } from '../activity-ByrD9Ftr.js';
2
+
3
+ interface RawSlackSlashCommandPayload {
4
+ command?: string;
5
+ text?: string;
6
+ response_url?: string;
7
+ trigger_id?: string;
8
+ user_id?: string;
9
+ user_name?: string;
10
+ team_id?: string;
11
+ team_domain?: string;
12
+ channel_id?: string;
13
+ channel_name?: string;
14
+ api_app_id?: string;
15
+ enterprise_id?: string;
16
+ enterprise_name?: string;
17
+ is_enterprise_install?: string | boolean;
18
+ [key: string]: unknown;
19
+ }
20
+ interface SlackSlashCommandEntrypoint {
21
+ kind: "slash-command";
22
+ command: string;
23
+ activity: SlackActivityInfo;
24
+ triggerId?: string;
25
+ responseUrl?: string;
26
+ userName?: string;
27
+ channelName?: string;
28
+ teamDomain?: string;
29
+ appId?: string;
30
+ enterpriseId?: string;
31
+ enterpriseName?: string;
32
+ isEnterpriseInstall?: boolean;
33
+ }
34
+ declare function parseSlackSlashCommandEntrypoint(payload: RawSlackSlashCommandPayload): SlackSlashCommandEntrypoint;
35
+
36
+ interface RawSlackShortcutUser {
37
+ id?: string;
38
+ name?: string;
39
+ username?: string;
40
+ team_id?: string;
41
+ [key: string]: unknown;
42
+ }
43
+ interface RawSlackShortcutTeam {
44
+ id?: string;
45
+ domain?: string;
46
+ enterprise_id?: string;
47
+ enterprise_name?: string;
48
+ [key: string]: unknown;
49
+ }
50
+ interface RawSlackShortcutEnterprise {
51
+ id?: string;
52
+ name?: string;
53
+ [key: string]: unknown;
54
+ }
55
+ interface RawSlackShortcutChannel {
56
+ id?: string;
57
+ name?: string;
58
+ [key: string]: unknown;
59
+ }
60
+ interface RawSlackShortcutMessage {
61
+ type?: string;
62
+ user?: string;
63
+ channel?: string;
64
+ ts?: string;
65
+ thread_ts?: string;
66
+ text?: string;
67
+ blocks?: unknown[];
68
+ attachments?: unknown[];
69
+ [key: string]: unknown;
70
+ }
71
+ interface RawSlackShortcutPayload {
72
+ type?: "shortcut" | "message_action" | string;
73
+ callback_id?: string;
74
+ trigger_id?: string;
75
+ response_url?: string;
76
+ action_ts?: string;
77
+ message_ts?: string;
78
+ user?: RawSlackShortcutUser;
79
+ team?: RawSlackShortcutTeam | null;
80
+ enterprise?: RawSlackShortcutEnterprise;
81
+ channel?: RawSlackShortcutChannel;
82
+ message?: RawSlackShortcutMessage;
83
+ is_enterprise_install?: boolean;
84
+ [key: string]: unknown;
85
+ }
86
+ interface SlackShortcutEntrypointBase {
87
+ callbackId: string;
88
+ triggerId?: string;
89
+ actionTs?: string;
90
+ userId: string;
91
+ userName?: string;
92
+ teamId?: string;
93
+ teamDomain?: string;
94
+ enterpriseId?: string;
95
+ enterpriseName?: string;
96
+ isEnterpriseInstall?: boolean;
97
+ }
98
+ interface SlackGlobalShortcutEntrypoint extends SlackShortcutEntrypointBase {
99
+ kind: "global-shortcut";
100
+ }
101
+ interface SlackMessageShortcutSelection {
102
+ channelId: string;
103
+ channelName?: string;
104
+ messageTs?: string;
105
+ threadTs?: string;
106
+ userId?: string;
107
+ text: string;
108
+ }
109
+ interface SlackMessageShortcutEntrypoint extends SlackShortcutEntrypointBase {
110
+ kind: "message-shortcut";
111
+ activity: SlackActivityInfo;
112
+ responseUrl?: string;
113
+ selectedMessage: SlackMessageShortcutSelection;
114
+ }
115
+ type SlackShortcutEntrypoint = SlackGlobalShortcutEntrypoint | SlackMessageShortcutEntrypoint;
116
+ declare function parseSlackShortcutEntrypoint(payload: RawSlackShortcutPayload): SlackShortcutEntrypoint;
117
+ declare function parseSlackGlobalShortcutEntrypoint(payload: RawSlackShortcutPayload): SlackGlobalShortcutEntrypoint;
118
+ declare function parseSlackMessageShortcutEntrypoint(payload: RawSlackShortcutPayload): SlackMessageShortcutEntrypoint;
119
+
120
+ export { type RawSlackShortcutChannel, type RawSlackShortcutEnterprise, type RawSlackShortcutMessage, type RawSlackShortcutPayload, type RawSlackShortcutTeam, type RawSlackShortcutUser, type RawSlackSlashCommandPayload, type SlackGlobalShortcutEntrypoint, type SlackMessageShortcutEntrypoint, type SlackMessageShortcutSelection, type SlackShortcutEntrypoint, type SlackShortcutEntrypointBase, type SlackSlashCommandEntrypoint, parseSlackGlobalShortcutEntrypoint, parseSlackMessageShortcutEntrypoint, parseSlackShortcutEntrypoint, parseSlackSlashCommandEntrypoint };
@@ -0,0 +1,132 @@
1
+ import {
2
+ extractSlackMessageText,
3
+ resolveSlackChannelType
4
+ } from "../chunk-FPCE5V5Y.js";
5
+
6
+ // src/entrypoints/commands.ts
7
+ function parseSlackSlashCommandEntrypoint(payload) {
8
+ const channelId = readString(payload.channel_id) ?? "unknown";
9
+ const teamId = readString(payload.team_id);
10
+ const text = readString(payload.text) ?? "";
11
+ const triggerId = readString(payload.trigger_id);
12
+ const responseUrl = readString(payload.response_url);
13
+ const userName = readString(payload.user_name);
14
+ const channelName = readString(payload.channel_name);
15
+ const teamDomain = readString(payload.team_domain);
16
+ const appId = readString(payload.api_app_id);
17
+ const enterpriseId = readString(payload.enterprise_id);
18
+ const enterpriseName = readString(payload.enterprise_name);
19
+ const activity = {
20
+ channelId,
21
+ channelType: resolveSlackChannelType(channelId, void 0, false),
22
+ userId: readString(payload.user_id) ?? "unknown",
23
+ ...teamId ? { teamId } : {},
24
+ text,
25
+ isMention: false
26
+ };
27
+ return {
28
+ kind: "slash-command",
29
+ command: readString(payload.command) ?? "unknown",
30
+ activity,
31
+ ...triggerId ? { triggerId } : {},
32
+ ...responseUrl ? { responseUrl } : {},
33
+ ...userName ? { userName } : {},
34
+ ...channelName ? { channelName } : {},
35
+ ...teamDomain ? { teamDomain } : {},
36
+ ...appId ? { appId } : {},
37
+ ...enterpriseId ? { enterpriseId } : {},
38
+ ...enterpriseName ? { enterpriseName } : {},
39
+ ...payload.is_enterprise_install !== void 0 ? {
40
+ isEnterpriseInstall: payload.is_enterprise_install === true || payload.is_enterprise_install === "true"
41
+ } : {}
42
+ };
43
+ }
44
+ function readString(value) {
45
+ return typeof value === "string" && value.trim() ? value.trim() : void 0;
46
+ }
47
+
48
+ // src/entrypoints/shortcuts.ts
49
+ function parseSlackShortcutEntrypoint(payload) {
50
+ return payload.type === "message_action" || payload.message ? parseSlackMessageShortcutEntrypoint(payload) : parseSlackGlobalShortcutEntrypoint(payload);
51
+ }
52
+ function parseSlackGlobalShortcutEntrypoint(payload) {
53
+ return {
54
+ kind: "global-shortcut",
55
+ ...parseShortcutBase(payload)
56
+ };
57
+ }
58
+ function parseSlackMessageShortcutEntrypoint(payload) {
59
+ const base = parseShortcutBase(payload);
60
+ const message = readRecord(payload.message) ?? {};
61
+ const channel = readRecord(payload.channel);
62
+ const channelId = readString2(channel?.id) ?? readString2(message.channel) ?? "unknown";
63
+ const messageTs = readString2(payload.message_ts) ?? readString2(message.ts) ?? void 0;
64
+ const threadTs = readString2(message.thread_ts);
65
+ const isThread = Boolean(threadTs && threadTs !== messageTs);
66
+ const responseUrl = readString2(payload.response_url);
67
+ const channelName = readString2(channel?.name);
68
+ const selectedMessageUserId = readString2(message.user);
69
+ const text = extractSlackMessageText(message, {
70
+ stripLeadingMentions: channelId.startsWith("D") ? false : true
71
+ });
72
+ const activity = {
73
+ channelId,
74
+ channelType: resolveSlackChannelType(channelId, threadTs, isThread),
75
+ userId: base.userId,
76
+ ...base.teamId ? { teamId: base.teamId } : {},
77
+ ...isThread ? { threadTs } : {},
78
+ ...messageTs ? { messageTs } : {},
79
+ text,
80
+ isMention: false
81
+ };
82
+ return {
83
+ kind: "message-shortcut",
84
+ ...base,
85
+ activity,
86
+ ...responseUrl ? { responseUrl } : {},
87
+ selectedMessage: {
88
+ channelId,
89
+ ...channelName ? { channelName } : {},
90
+ ...messageTs ? { messageTs } : {},
91
+ ...threadTs ? { threadTs } : {},
92
+ ...selectedMessageUserId ? { userId: selectedMessageUserId } : {},
93
+ text
94
+ }
95
+ };
96
+ }
97
+ function parseShortcutBase(payload) {
98
+ const user = readRecord(payload.user);
99
+ const team = readRecord(payload.team);
100
+ const enterprise = readRecord(payload.enterprise);
101
+ const teamId = readString2(team?.id) ?? readString2(user?.team_id);
102
+ const enterpriseId = readString2(enterprise?.id) ?? readString2(team?.enterprise_id);
103
+ const enterpriseName = readString2(enterprise?.name) ?? readString2(team?.enterprise_name);
104
+ const triggerId = readString2(payload.trigger_id);
105
+ const actionTs = readString2(payload.action_ts);
106
+ const userName = readString2(user?.name) ?? readString2(user?.username);
107
+ const teamDomain = readString2(team?.domain);
108
+ return {
109
+ callbackId: readString2(payload.callback_id) ?? "unknown",
110
+ userId: readString2(user?.id) ?? "unknown",
111
+ ...triggerId ? { triggerId } : {},
112
+ ...actionTs ? { actionTs } : {},
113
+ ...userName ? { userName } : {},
114
+ ...teamId ? { teamId } : {},
115
+ ...teamDomain ? { teamDomain } : {},
116
+ ...enterpriseId ? { enterpriseId } : {},
117
+ ...enterpriseName ? { enterpriseName } : {},
118
+ ...payload.is_enterprise_install !== void 0 ? { isEnterpriseInstall: payload.is_enterprise_install } : {}
119
+ };
120
+ }
121
+ function readRecord(value) {
122
+ return value && typeof value === "object" && !Array.isArray(value) ? value : void 0;
123
+ }
124
+ function readString2(value) {
125
+ return typeof value === "string" && value.trim() ? value.trim() : void 0;
126
+ }
127
+ export {
128
+ parseSlackGlobalShortcutEntrypoint,
129
+ parseSlackMessageShortcutEntrypoint,
130
+ parseSlackShortcutEntrypoint,
131
+ parseSlackSlashCommandEntrypoint
132
+ };
@@ -1,6 +1,6 @@
1
- import { S as SlackActivityInfo } from './activity-ByrD9Ftr.js';
1
+ import { S as SlackActivityInfo } from '../activity-ByrD9Ftr.js';
2
2
  import { ConversationsHistoryResponse, ConversationsRepliesResponse, WebClient } from '@slack/web-api';
3
- import { L as Logger } from './logging-Bl3HfcC8.js';
3
+ import { L as Logger } from '../logging-Bl3HfcC8.js';
4
4
 
5
5
  type SlackContextFragmentRole = "system" | "user";
6
6
  type SlackContextFragmentPlacement = "before-history" | "after-latest-user" | "after-history";
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  extractSlackMessageText
3
- } from "./chunk-FPCE5V5Y.js";
3
+ } from "../chunk-FPCE5V5Y.js";
4
4
 
5
5
  // src/history/context/assistant-root.ts
6
6
  function normalizeAssistantSurfaceThreadRootMessages(messages, options) {
package/dist/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
1
  export { S as SlackActivityInfo, a as SlackChannelType, b as SlackUserIdentity } from './activity-ByrD9Ftr.js';
2
2
  export { ExtractSlackMessageTextOptions, RawSlackActionTokenPayload, RawSlackAppMentionPayload, RawSlackAssistantThreadPayload, RawSlackMessagePayload, SlackAmbientTurnContext, SlackApprovalRequest, SlackAssistantStatusUpdate, SlackAssistantSuggestedPrompt, SlackAssistantSuggestedPrompts, SlackAssistantTaskDisplayMode, SlackAssistantThreadContext, SlackAssistantUtilities, SlackAuthContext, SlackChatStreamStartArgs, SlackEventInteractiveRequestHandler, SlackHumanInputRequest, SlackInteractiveMessage, SlackInteractiveMessageRef, SlackInteractiveRequest, SlackInteractiveRequestBaseContext, SlackInteractiveRequestContext, SlackInteractiveRequestHandler, SlackInteractiveRequestKind, SlackInteractiveResponder, SlackMessageAuthorshipOptions, SlackMessageFormatter, SlackMessageFormattingOptions, SlackMessageTextPayload, SlackThreadStatusSetter, SlackTurnPreparation, SlackTurnRequestContext, currentSlackTurnContext, extractSlackActionToken, extractSlackAttachmentsText, extractSlackAuthContext, extractSlackBlocksText, extractSlackMessageText, extractSlackUserIdentity, formatSlackAttributedFollowUp, isProcessableMessage, markdownToSlackMrkdwn, parseSlackMentionActivity, parseSlackMessageActivity, resolveSlackChannelType, resolveSlackMessageFormatter, resolveThreadAwareSlackSessionId, runWithSlackTurnContext, stripLeadingMentions } from './core.js';
3
- export { PostgresSlackMessagePolicyPruneResult, PostgresSlackMessagePolicyStateStore, PostgresSlackMessagePolicyStateStoreOptions, SlackAsyncMessagePolicyConfig, SlackAsyncMessagePolicyResolver, SlackChannelMessagePolicy, SlackMentionedThreadState, SlackMessagePolicyAcceptReason, SlackMessagePolicyAcceptedDecision, SlackMessagePolicyConfig, SlackMessagePolicyDecision, SlackMessagePolicyPostgresClient, SlackMessagePolicyRejectReason, SlackMessagePolicyRejectedDecision, SlackMessagePolicyResolver, SlackMessagePolicyStateContext, SlackMessagePolicyStateStore, SlackSyncMessagePolicyStateStore, SlackThreadReplyPolicy, createAsyncSlackMessagePolicyResolver, createInMemorySlackMessagePolicyStateStore, createPostgresSlackMessagePolicyStateStore, createSlackMessagePolicyMessageKey, createSlackMessagePolicyResolver, createSlackMessagePolicyThreadKey, initializePostgresSlackMessagePolicyState, prunePostgresSlackMessagePolicyState, shouldRegisterSlackPassiveChannelMessages } from './policy.js';
3
+ export { InMemorySlackThreadParticipationStateStoreOptions, PostgresSlackMessagePolicyPruneResult, PostgresSlackMessagePolicyStateStore, PostgresSlackMessagePolicyStateStoreOptions, PostgresSlackThreadParticipationStateStore, PostgresSlackThreadParticipationStateStoreOptions, SlackAsyncMessagePolicyConfig, SlackAsyncMessagePolicyResolver, SlackChannelMessagePolicy, SlackMentionedThreadState, SlackMessagePolicyAcceptReason, SlackMessagePolicyAcceptedDecision, SlackMessagePolicyConfig, SlackMessagePolicyDecision, SlackMessagePolicyPostgresClient, SlackMessagePolicyRejectReason, SlackMessagePolicyRejectedDecision, SlackMessagePolicyResolver, SlackMessagePolicyStateContext, SlackMessagePolicyStateStore, SlackQuietThreadRejectedDecision, SlackSyncMessagePolicyStateStore, SlackThreadAwareMessagePolicyConfig, SlackThreadAwareMessagePolicyDecision, SlackThreadAwareMessagePolicyResolver, SlackThreadParticipationEligibility, SlackThreadParticipationEligibilityOptions, SlackThreadParticipationMode, SlackThreadParticipationPostgresClient, SlackThreadParticipationPruneResult, SlackThreadParticipationReactivation, SlackThreadParticipationState, SlackThreadParticipationStateContext, SlackThreadParticipationStateStore, SlackThreadReplyPolicy, createAsyncSlackMessagePolicyResolver, createAsyncSlackThreadAwareMessagePolicyResolver, createInMemorySlackMessagePolicyStateStore, createInMemorySlackThreadParticipationStateStore, createPostgresSlackMessagePolicyStateStore, createPostgresSlackThreadParticipationStateStore, createSlackMessagePolicyMessageKey, createSlackMessagePolicyResolver, createSlackMessagePolicyThreadKey, initializePostgresSlackMessagePolicyState, initializePostgresSlackThreadParticipationState, prunePostgresSlackMessagePolicyState, prunePostgresSlackThreadParticipationState, resolveSlackThreadParticipationEligibility, shouldRegisterSlackPassiveChannelMessages } from './policy/index.js';
4
4
  export { L as Logger } from './logging-Bl3HfcC8.js';
package/dist/index.js CHANGED
@@ -1,12 +1,30 @@
1
- import "./chunk-NE57BLLU.js";
1
+ import {
2
+ createAsyncSlackMessagePolicyResolver,
3
+ createAsyncSlackThreadAwareMessagePolicyResolver,
4
+ createInMemorySlackMessagePolicyStateStore,
5
+ createInMemorySlackThreadParticipationStateStore,
6
+ createPostgresSlackMessagePolicyStateStore,
7
+ createPostgresSlackThreadParticipationStateStore,
8
+ createSlackMessagePolicyMessageKey,
9
+ createSlackMessagePolicyResolver,
10
+ createSlackMessagePolicyThreadKey,
11
+ initializePostgresSlackMessagePolicyState,
12
+ initializePostgresSlackThreadParticipationState,
13
+ prunePostgresSlackMessagePolicyState,
14
+ prunePostgresSlackThreadParticipationState,
15
+ resolveSlackThreadParticipationEligibility,
16
+ shouldRegisterSlackPassiveChannelMessages
17
+ } from "./chunk-DNVSH7H5.js";
2
18
  import {
3
19
  currentSlackTurnContext,
4
20
  formatSlackAttributedFollowUp,
5
- markdownToSlackMrkdwn,
6
- resolveSlackMessageFormatter,
7
21
  resolveThreadAwareSlackSessionId,
8
22
  runWithSlackTurnContext
9
- } from "./chunk-JZG4IETE.js";
23
+ } from "./chunk-X4WBBBYM.js";
24
+ import {
25
+ markdownToSlackMrkdwn,
26
+ resolveSlackMessageFormatter
27
+ } from "./chunk-6WHFQUYQ.js";
10
28
  import {
11
29
  extractSlackActionToken,
12
30
  extractSlackAuthContext,
@@ -22,21 +40,13 @@ import {
22
40
  resolveSlackChannelType,
23
41
  stripLeadingMentions
24
42
  } from "./chunk-FPCE5V5Y.js";
25
- import {
26
- createAsyncSlackMessagePolicyResolver,
27
- createInMemorySlackMessagePolicyStateStore,
28
- createPostgresSlackMessagePolicyStateStore,
29
- createSlackMessagePolicyMessageKey,
30
- createSlackMessagePolicyResolver,
31
- createSlackMessagePolicyThreadKey,
32
- initializePostgresSlackMessagePolicyState,
33
- prunePostgresSlackMessagePolicyState,
34
- shouldRegisterSlackPassiveChannelMessages
35
- } from "./chunk-CMR6B76C.js";
36
43
  export {
37
44
  createAsyncSlackMessagePolicyResolver,
45
+ createAsyncSlackThreadAwareMessagePolicyResolver,
38
46
  createInMemorySlackMessagePolicyStateStore,
47
+ createInMemorySlackThreadParticipationStateStore,
39
48
  createPostgresSlackMessagePolicyStateStore,
49
+ createPostgresSlackThreadParticipationStateStore,
40
50
  createSlackMessagePolicyMessageKey,
41
51
  createSlackMessagePolicyResolver,
42
52
  createSlackMessagePolicyThreadKey,
@@ -49,13 +59,16 @@ export {
49
59
  extractSlackUserIdentity,
50
60
  formatSlackAttributedFollowUp,
51
61
  initializePostgresSlackMessagePolicyState,
62
+ initializePostgresSlackThreadParticipationState,
52
63
  isProcessableMessage,
53
64
  markdownToSlackMrkdwn,
54
65
  parseSlackMentionActivity,
55
66
  parseSlackMessageActivity,
56
67
  prunePostgresSlackMessagePolicyState,
68
+ prunePostgresSlackThreadParticipationState,
57
69
  resolveSlackChannelType,
58
70
  resolveSlackMessageFormatter,
71
+ resolveSlackThreadParticipationEligibility,
59
72
  resolveThreadAwareSlackSessionId,
60
73
  runWithSlackTurnContext,
61
74
  shouldRegisterSlackPassiveChannelMessages,
@@ -1,4 +1,4 @@
1
- import { S as SlackActivityInfo } from './activity-ByrD9Ftr.js';
1
+ import { S as SlackActivityInfo } from '../activity-ByrD9Ftr.js';
2
2
 
3
3
  type MaybePromise<T> = T | Promise<T>;
4
4
  type SlackChannelMessagePolicy = "disabled" | "mentioned-threads" | "allowed-channels" | "any-added-channel";
@@ -173,4 +173,105 @@ declare function createInMemorySlackMessagePolicyStateStore({ maxAcceptedMessage
173
173
  maxMentionedThreads?: number;
174
174
  }): SlackSyncMessagePolicyStateStore;
175
175
 
176
- export { type PostgresSlackMessagePolicyPruneResult, type PostgresSlackMessagePolicyStateStore, type PostgresSlackMessagePolicyStateStoreOptions, type SlackAsyncMessagePolicyConfig, type SlackAsyncMessagePolicyResolver, type SlackChannelMessagePolicy, type SlackMentionedThreadState, type SlackMessagePolicyAcceptReason, type SlackMessagePolicyAcceptedDecision, type SlackMessagePolicyConfig, type SlackMessagePolicyDecision, type SlackMessagePolicyPostgresClient, type SlackMessagePolicyRejectReason, type SlackMessagePolicyRejectedDecision, type SlackMessagePolicyResolver, type SlackMessagePolicyStateContext, type SlackMessagePolicyStateStore, type SlackSyncMessagePolicyStateStore, type SlackThreadReplyPolicy, createAsyncSlackMessagePolicyResolver, createInMemorySlackMessagePolicyStateStore, createPostgresSlackMessagePolicyStateStore, createSlackMessagePolicyMessageKey, createSlackMessagePolicyResolver, createSlackMessagePolicyThreadKey, initializePostgresSlackMessagePolicyState, prunePostgresSlackMessagePolicyState, shouldRegisterSlackPassiveChannelMessages };
176
+ type SlackThreadParticipationMode = "quiet" | "active";
177
+ interface SlackThreadParticipationState {
178
+ mode: "quiet";
179
+ reason?: string;
180
+ sourceMessageTs?: string;
181
+ updatedAt?: string;
182
+ updatedByUserId?: string;
183
+ }
184
+ interface SlackThreadParticipationStateContext {
185
+ activity: SlackActivityInfo;
186
+ key: string;
187
+ }
188
+ interface SlackThreadParticipationPruneResult {
189
+ quietThreadsDeleted: number;
190
+ }
191
+ interface SlackThreadParticipationStateStore {
192
+ get(key: string, context: SlackThreadParticipationStateContext): Promise<SlackThreadParticipationState | undefined>;
193
+ setQuiet(key: string, state: Omit<SlackThreadParticipationState, "mode" | "updatedAt">, context: SlackThreadParticipationStateContext): Promise<void>;
194
+ clear(key: string, context: SlackThreadParticipationStateContext): Promise<void>;
195
+ close?(): Promise<void>;
196
+ prune?(): Promise<SlackThreadParticipationPruneResult>;
197
+ }
198
+ interface SlackThreadParticipationEligibility {
199
+ available: boolean;
200
+ reason?: string;
201
+ threadKey?: string;
202
+ threadTs?: string;
203
+ }
204
+ interface SlackThreadParticipationEligibilityOptions {
205
+ activity: SlackActivityInfo;
206
+ policy: Pick<SlackMessagePolicyConfig, "messagePolicy" | "threadReplyPolicy">;
207
+ stateStore?: SlackThreadParticipationStateStore;
208
+ }
209
+ interface InMemorySlackThreadParticipationStateStoreOptions {
210
+ maxThreads?: number;
211
+ now?: () => Date;
212
+ }
213
+ interface SlackThreadParticipationPostgresClient {
214
+ end?: () => Promise<void>;
215
+ query<T = unknown>(sql: string, values?: readonly unknown[]): Promise<{
216
+ rows: T[];
217
+ rowCount?: number | null;
218
+ }>;
219
+ }
220
+ interface PostgresSlackThreadParticipationStateStoreOptions {
221
+ client?: SlackThreadParticipationPostgresClient;
222
+ connectionString?: string;
223
+ ensureSchema?: boolean;
224
+ onPruneError?: (error: unknown) => void;
225
+ pruneBatchSize?: number;
226
+ pruneIntervalMs?: number;
227
+ retentionMs?: number;
228
+ schema?: string;
229
+ tableName?: string;
230
+ }
231
+ interface PostgresSlackThreadParticipationStateStore extends SlackThreadParticipationStateStore {
232
+ close(): Promise<void>;
233
+ prune(): Promise<SlackThreadParticipationPruneResult>;
234
+ }
235
+ declare function resolveSlackThreadParticipationEligibility({ activity, policy, stateStore, }: SlackThreadParticipationEligibilityOptions): SlackThreadParticipationEligibility;
236
+ declare function createInMemorySlackThreadParticipationStateStore({ maxThreads, now, }?: InMemorySlackThreadParticipationStateStoreOptions): SlackThreadParticipationStateStore;
237
+ declare function createPostgresSlackThreadParticipationStateStore({ client, connectionString, ensureSchema, onPruneError, pruneBatchSize, pruneIntervalMs, retentionMs, schema, tableName, }: PostgresSlackThreadParticipationStateStoreOptions): PostgresSlackThreadParticipationStateStore;
238
+ declare function initializePostgresSlackThreadParticipationState({ client, ensureSchema, schema, tableName, }: {
239
+ client: SlackThreadParticipationPostgresClient;
240
+ ensureSchema?: boolean;
241
+ schema?: string;
242
+ tableName?: string;
243
+ }): Promise<void>;
244
+ declare function prunePostgresSlackThreadParticipationState({ client, pruneBatchSize, retentionMs, schema, tableName, }: {
245
+ client: SlackThreadParticipationPostgresClient;
246
+ pruneBatchSize?: number;
247
+ retentionMs?: number;
248
+ schema?: string;
249
+ tableName?: string;
250
+ }): Promise<SlackThreadParticipationPruneResult>;
251
+
252
+ interface SlackThreadParticipationReactivation {
253
+ reason?: string;
254
+ threadKey: string;
255
+ threadTs?: string;
256
+ }
257
+ interface SlackQuietThreadRejectedDecision {
258
+ accepted: false;
259
+ activity: SlackActivityInfo;
260
+ reason: "quiet-thread";
261
+ threadKey: string;
262
+ threadParticipationReason?: string;
263
+ threadTs?: string;
264
+ }
265
+ type SlackThreadAwareMessagePolicyDecision = (SlackMessagePolicyDecision & {
266
+ reactivatedThreadParticipation?: SlackThreadParticipationReactivation;
267
+ }) | SlackQuietThreadRejectedDecision;
268
+ interface SlackThreadAwareMessagePolicyResolver {
269
+ resolve(activity: SlackActivityInfo): Promise<SlackThreadAwareMessagePolicyDecision>;
270
+ resolveMessage(activity: SlackActivityInfo): Promise<string | undefined>;
271
+ }
272
+ interface SlackThreadAwareMessagePolicyConfig extends SlackAsyncMessagePolicyConfig {
273
+ threadParticipationStore?: SlackThreadParticipationStateStore;
274
+ }
275
+ declare function createAsyncSlackThreadAwareMessagePolicyResolver(config?: SlackThreadAwareMessagePolicyConfig): SlackThreadAwareMessagePolicyResolver;
276
+
277
+ export { type InMemorySlackThreadParticipationStateStoreOptions, type PostgresSlackMessagePolicyPruneResult, type PostgresSlackMessagePolicyStateStore, type PostgresSlackMessagePolicyStateStoreOptions, type PostgresSlackThreadParticipationStateStore, type PostgresSlackThreadParticipationStateStoreOptions, type SlackAsyncMessagePolicyConfig, type SlackAsyncMessagePolicyResolver, type SlackChannelMessagePolicy, type SlackMentionedThreadState, type SlackMessagePolicyAcceptReason, type SlackMessagePolicyAcceptedDecision, type SlackMessagePolicyConfig, type SlackMessagePolicyDecision, type SlackMessagePolicyPostgresClient, type SlackMessagePolicyRejectReason, type SlackMessagePolicyRejectedDecision, type SlackMessagePolicyResolver, type SlackMessagePolicyStateContext, type SlackMessagePolicyStateStore, type SlackQuietThreadRejectedDecision, type SlackSyncMessagePolicyStateStore, type SlackThreadAwareMessagePolicyConfig, type SlackThreadAwareMessagePolicyDecision, type SlackThreadAwareMessagePolicyResolver, type SlackThreadParticipationEligibility, type SlackThreadParticipationEligibilityOptions, type SlackThreadParticipationMode, type SlackThreadParticipationPostgresClient, type SlackThreadParticipationPruneResult, type SlackThreadParticipationReactivation, type SlackThreadParticipationState, type SlackThreadParticipationStateContext, type SlackThreadParticipationStateStore, type SlackThreadReplyPolicy, createAsyncSlackMessagePolicyResolver, createAsyncSlackThreadAwareMessagePolicyResolver, createInMemorySlackMessagePolicyStateStore, createInMemorySlackThreadParticipationStateStore, createPostgresSlackMessagePolicyStateStore, createPostgresSlackThreadParticipationStateStore, createSlackMessagePolicyMessageKey, createSlackMessagePolicyResolver, createSlackMessagePolicyThreadKey, initializePostgresSlackMessagePolicyState, initializePostgresSlackThreadParticipationState, prunePostgresSlackMessagePolicyState, prunePostgresSlackThreadParticipationState, resolveSlackThreadParticipationEligibility, shouldRegisterSlackPassiveChannelMessages };
@@ -1,22 +1,34 @@
1
1
  import {
2
2
  createAsyncSlackMessagePolicyResolver,
3
+ createAsyncSlackThreadAwareMessagePolicyResolver,
3
4
  createInMemorySlackMessagePolicyStateStore,
5
+ createInMemorySlackThreadParticipationStateStore,
4
6
  createPostgresSlackMessagePolicyStateStore,
7
+ createPostgresSlackThreadParticipationStateStore,
5
8
  createSlackMessagePolicyMessageKey,
6
9
  createSlackMessagePolicyResolver,
7
10
  createSlackMessagePolicyThreadKey,
8
11
  initializePostgresSlackMessagePolicyState,
12
+ initializePostgresSlackThreadParticipationState,
9
13
  prunePostgresSlackMessagePolicyState,
14
+ prunePostgresSlackThreadParticipationState,
15
+ resolveSlackThreadParticipationEligibility,
10
16
  shouldRegisterSlackPassiveChannelMessages
11
- } from "./chunk-CMR6B76C.js";
17
+ } from "../chunk-DNVSH7H5.js";
12
18
  export {
13
19
  createAsyncSlackMessagePolicyResolver,
20
+ createAsyncSlackThreadAwareMessagePolicyResolver,
14
21
  createInMemorySlackMessagePolicyStateStore,
22
+ createInMemorySlackThreadParticipationStateStore,
15
23
  createPostgresSlackMessagePolicyStateStore,
24
+ createPostgresSlackThreadParticipationStateStore,
16
25
  createSlackMessagePolicyMessageKey,
17
26
  createSlackMessagePolicyResolver,
18
27
  createSlackMessagePolicyThreadKey,
19
28
  initializePostgresSlackMessagePolicyState,
29
+ initializePostgresSlackThreadParticipationState,
20
30
  prunePostgresSlackMessagePolicyState,
31
+ prunePostgresSlackThreadParticipationState,
32
+ resolveSlackThreadParticipationEligibility,
21
33
  shouldRegisterSlackPassiveChannelMessages
22
34
  };
@@ -0,0 +1,53 @@
1
+ import { Logger } from '@slack/bolt';
2
+ import { L as Logger$1 } from './logging-Bl3HfcC8.js';
3
+
4
+ type SlackSocketModeRuntimePolicy = "single-instance" | "external-coordination";
5
+ interface SlackSocketModeReceiverRuntimeOptions {
6
+ autoReconnectEnabled?: boolean;
7
+ clientPingTimeout?: number;
8
+ pingPongLoggingEnabled?: boolean;
9
+ serverPingTimeout?: number;
10
+ }
11
+ interface SlackSocketModeRuntimeOptions {
12
+ appSlug: string;
13
+ appToken?: string;
14
+ autoReconnectEnabled?: boolean;
15
+ clientPingTimeoutMs?: number;
16
+ exitProcess?: (code: number) => never | void;
17
+ lockDir?: string;
18
+ lockEnabled?: boolean;
19
+ logger?: Logger$1;
20
+ logLevel?: "debug" | "info" | "warn" | "error";
21
+ pingPongLoggingEnabled?: boolean;
22
+ restartGuardEnabled?: boolean;
23
+ restartGuardMaxWarnings?: number;
24
+ restartGuardWindowMs?: number;
25
+ runtimePolicy?: SlackSocketModeRuntimePolicy;
26
+ serverPingTimeoutMs?: number;
27
+ }
28
+ interface SlackSocketModeRuntime {
29
+ boltAppOptions: {
30
+ logger: Logger;
31
+ };
32
+ close(): void;
33
+ socketModeReceiverOptions: SlackSocketModeReceiverRuntimeOptions;
34
+ }
35
+ interface SlackSocketModeRestartGuard {
36
+ record(message: string): void;
37
+ }
38
+ declare function createSlackSocketModeRuntime({ appSlug, appToken, autoReconnectEnabled, clientPingTimeoutMs, exitProcess, lockDir, lockEnabled, logger, logLevel, pingPongLoggingEnabled, restartGuardEnabled, restartGuardMaxWarnings, restartGuardWindowMs, runtimePolicy, serverPingTimeoutMs, }: SlackSocketModeRuntimeOptions): SlackSocketModeRuntime;
39
+ declare function createSlackSocketModeRestartGuard({ enabled, exitProcess, logger, maxWarnings, windowMs, }: {
40
+ enabled: boolean;
41
+ exitProcess: (code: number) => never | void;
42
+ logger?: Logger$1;
43
+ maxWarnings: number;
44
+ windowMs: number;
45
+ }): SlackSocketModeRestartGuard;
46
+ declare function createSlackSdkLogger({ level, logger, restartGuard, }: {
47
+ level: "debug" | "info" | "warn" | "error";
48
+ logger?: Logger$1;
49
+ restartGuard?: SlackSocketModeRestartGuard;
50
+ }): Logger;
51
+ declare function redactSlackSocketModeLogValue(value: unknown, depth?: number): unknown;
52
+
53
+ export { type SlackSocketModeReceiverRuntimeOptions as S, type SlackSocketModeRestartGuard as a, type SlackSocketModeRuntime as b, type SlackSocketModeRuntimeOptions as c, type SlackSocketModeRuntimePolicy as d, createSlackSdkLogger as e, createSlackSocketModeRestartGuard as f, createSlackSocketModeRuntime as g, redactSlackSocketModeLogValue as r };