@cuylabs/channel-slack 0.7.0 → 0.9.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 +3 -2
- package/dist/artifacts/index.d.ts +3 -110
- package/dist/chunk-3KP3CBCC.js +175 -0
- package/dist/core.d.ts +5 -40
- package/dist/core.js +15 -1
- package/dist/index.d.ts +5 -1
- package/dist/index.js +15 -1
- package/dist/interactive/index.d.ts +154 -0
- package/dist/interactive/index.js +650 -0
- package/dist/interactive-CbKYkkc_.d.ts +46 -0
- package/dist/responses/index.d.ts +74 -0
- package/dist/responses/index.js +0 -0
- package/dist/turn-controls/index.d.ts +51 -0
- package/dist/turn-controls/index.js +16 -0
- package/dist/types-C8nkPuD4.d.ts +111 -0
- package/docs/reference/channel-slack-boundary.md +5 -2
- package/docs/reference/exports.md +2 -0
- package/package.json +18 -3
- /package/dist/{chunk-X4WBBBYM.js → chunk-ISOMBQXE.js} +0 -0
package/README.md
CHANGED
|
@@ -4,8 +4,9 @@ Agent-runtime-agnostic Slack channel primitives.
|
|
|
4
4
|
|
|
5
5
|
This package owns reusable Slack mechanics: event parsing, message admission,
|
|
6
6
|
history loading, formatting, setup inspection, auth helpers, entrypoint
|
|
7
|
-
normalization, artifact publishing,
|
|
8
|
-
|
|
7
|
+
normalization, artifact publishing, interactive request rendering/storage,
|
|
8
|
+
response sink contracts, and HTTP or Socket Mode transport helpers. It does not
|
|
9
|
+
create or run an agent, and it does not depend on an agent SDK.
|
|
9
10
|
|
|
10
11
|
Runtime-specific adapters should compose these primitives with their own turn
|
|
11
12
|
types, event streams, tools, prompts, and deployment policy.
|
|
@@ -1,112 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
interface SlackArtifactBase {
|
|
4
|
-
kind: string;
|
|
5
|
-
title: string;
|
|
6
|
-
summary?: string;
|
|
7
|
-
metadata?: Record<string, unknown>;
|
|
8
|
-
}
|
|
9
|
-
interface SlackTextArtifact extends SlackArtifactBase {
|
|
10
|
-
kind: "text";
|
|
11
|
-
text: string;
|
|
12
|
-
filename?: string;
|
|
13
|
-
mimeType?: string;
|
|
14
|
-
publishAs?: "message" | "file";
|
|
15
|
-
}
|
|
16
|
-
interface SlackFileArtifact extends SlackArtifactBase {
|
|
17
|
-
kind: "file";
|
|
18
|
-
filename: string;
|
|
19
|
-
data?: SlackArtifactBinaryData;
|
|
20
|
-
filePath?: string;
|
|
21
|
-
mimeType?: string;
|
|
22
|
-
initialComment?: string;
|
|
23
|
-
}
|
|
24
|
-
interface SlackImageArtifact extends SlackArtifactBase {
|
|
25
|
-
kind: "image";
|
|
26
|
-
filename: string;
|
|
27
|
-
altText: string;
|
|
28
|
-
data?: SlackArtifactBinaryData;
|
|
29
|
-
filePath?: string;
|
|
30
|
-
initialComment?: string;
|
|
31
|
-
}
|
|
32
|
-
interface SlackLinkArtifact extends SlackArtifactBase {
|
|
33
|
-
kind: "link";
|
|
34
|
-
url: string;
|
|
35
|
-
}
|
|
36
|
-
interface SlackCanvasArtifact extends SlackArtifactBase {
|
|
37
|
-
kind: "canvas";
|
|
38
|
-
markdown: string;
|
|
39
|
-
/**
|
|
40
|
-
* When set, updates an existing canvas instead of creating one.
|
|
41
|
-
*/
|
|
42
|
-
canvasId?: string;
|
|
43
|
-
/**
|
|
44
|
-
* Create a channel canvas when a channel is available.
|
|
45
|
-
*
|
|
46
|
-
* @default true
|
|
47
|
-
*/
|
|
48
|
-
channelCanvas?: boolean;
|
|
49
|
-
}
|
|
50
|
-
type SlackArtifact = SlackTextArtifact | SlackFileArtifact | SlackImageArtifact | SlackLinkArtifact | SlackCanvasArtifact;
|
|
51
|
-
interface SlackArtifactPostMessageResponse {
|
|
52
|
-
ok?: boolean;
|
|
53
|
-
channel?: string;
|
|
54
|
-
ts?: string;
|
|
55
|
-
[key: string]: unknown;
|
|
56
|
-
}
|
|
57
|
-
interface SlackArtifactFileUploadResponse {
|
|
58
|
-
ok?: boolean;
|
|
59
|
-
file?: {
|
|
60
|
-
id?: string;
|
|
61
|
-
[key: string]: unknown;
|
|
62
|
-
};
|
|
63
|
-
files?: Array<{
|
|
64
|
-
id?: string;
|
|
65
|
-
[key: string]: unknown;
|
|
66
|
-
}>;
|
|
67
|
-
[key: string]: unknown;
|
|
68
|
-
}
|
|
69
|
-
interface SlackArtifactCanvasResponse {
|
|
70
|
-
ok?: boolean;
|
|
71
|
-
canvas_id?: string;
|
|
72
|
-
[key: string]: unknown;
|
|
73
|
-
}
|
|
74
|
-
interface SlackArtifactClient {
|
|
75
|
-
chat?: {
|
|
76
|
-
postMessage(args: Record<string, unknown>): Promise<SlackArtifactPostMessageResponse>;
|
|
77
|
-
};
|
|
78
|
-
files?: {
|
|
79
|
-
uploadV2(args: Record<string, unknown>): Promise<SlackArtifactFileUploadResponse>;
|
|
80
|
-
};
|
|
81
|
-
canvases?: {
|
|
82
|
-
create(args?: Record<string, unknown>): Promise<SlackArtifactCanvasResponse>;
|
|
83
|
-
edit?(args: Record<string, unknown>): Promise<SlackArtifactCanvasResponse>;
|
|
84
|
-
};
|
|
85
|
-
conversations?: {
|
|
86
|
-
canvases?: {
|
|
87
|
-
create(args: Record<string, unknown>): Promise<SlackArtifactCanvasResponse>;
|
|
88
|
-
};
|
|
89
|
-
};
|
|
90
|
-
}
|
|
91
|
-
interface PublishSlackArtifactOptions {
|
|
92
|
-
client: SlackArtifactClient;
|
|
93
|
-
artifact: SlackArtifact;
|
|
94
|
-
channelId?: string;
|
|
95
|
-
threadTs?: string;
|
|
96
|
-
token?: string;
|
|
97
|
-
unfurlLinks?: boolean;
|
|
98
|
-
unfurlMedia?: boolean;
|
|
99
|
-
}
|
|
100
|
-
interface SlackArtifactPublication {
|
|
101
|
-
artifact: SlackArtifact;
|
|
102
|
-
method: SlackArtifactPublishMethod;
|
|
103
|
-
response: unknown;
|
|
104
|
-
channelId?: string;
|
|
105
|
-
threadTs?: string;
|
|
106
|
-
messageTs?: string;
|
|
107
|
-
fileId?: string;
|
|
108
|
-
canvasId?: string;
|
|
109
|
-
}
|
|
1
|
+
import { S as SlackArtifact, l as SlackLinkArtifact, P as PublishSlackArtifactOptions, g as SlackArtifactPublication, i as SlackCanvasArtifact, j as SlackFileArtifact, k as SlackImageArtifact, m as SlackTextArtifact } from '../types-C8nkPuD4.js';
|
|
2
|
+
export { a as SlackArtifactBase, b as SlackArtifactBinaryData, c as SlackArtifactCanvasResponse, d as SlackArtifactClient, e as SlackArtifactFileUploadResponse, f as SlackArtifactPostMessageResponse, h as SlackArtifactPublishMethod } from '../types-C8nkPuD4.js';
|
|
110
3
|
|
|
111
4
|
interface SlackArtifactBlockKitMessage {
|
|
112
5
|
text: string;
|
|
@@ -132,4 +25,4 @@ declare function publishSlackCanvasArtifact(options: PublishSlackArtifactOptions
|
|
|
132
25
|
artifact: SlackCanvasArtifact;
|
|
133
26
|
}): Promise<SlackArtifactPublication>;
|
|
134
27
|
|
|
135
|
-
export {
|
|
28
|
+
export { PublishSlackArtifactOptions, SlackArtifact, type SlackArtifactBlockKitMessage, SlackArtifactPublication, SlackCanvasArtifact, SlackFileArtifact, SlackImageArtifact, SlackLinkArtifact, SlackTextArtifact, createSlackArtifactBlocks, createSlackLinkArtifactBlocks, publishSlackArtifact, publishSlackCanvasArtifact, publishSlackFileArtifact, publishSlackImageArtifact, publishSlackLinkArtifact, publishSlackTextArtifact };
|
|
@@ -0,0 +1,175 @@
|
|
|
1
|
+
// src/turn-controls/block.ts
|
|
2
|
+
var SLACK_TURN_CANCEL_ACTION_ID = "agent_turn_cancel";
|
|
3
|
+
function createSlackTurnCancelMessage(options) {
|
|
4
|
+
const actionId = resolveSlackTurnCancelActionId(options.actionId);
|
|
5
|
+
const controlId = options.controlId.trim();
|
|
6
|
+
if (!controlId) {
|
|
7
|
+
throw new Error(
|
|
8
|
+
"createSlackTurnCancelMessage: controlId must be a non-empty string"
|
|
9
|
+
);
|
|
10
|
+
}
|
|
11
|
+
const text = (options.messageText ?? "Request controls").trim();
|
|
12
|
+
if (!text) {
|
|
13
|
+
throw new Error(
|
|
14
|
+
"createSlackTurnCancelMessage: messageText must be a non-empty string"
|
|
15
|
+
);
|
|
16
|
+
}
|
|
17
|
+
const buttonText = (options.buttonText ?? "Cancel").trim();
|
|
18
|
+
if (!buttonText) {
|
|
19
|
+
throw new Error(
|
|
20
|
+
"createSlackTurnCancelMessage: buttonText must be a non-empty string"
|
|
21
|
+
);
|
|
22
|
+
}
|
|
23
|
+
const value = encodeSlackTurnCancelButtonValue({
|
|
24
|
+
action: "cancel",
|
|
25
|
+
controlId,
|
|
26
|
+
...options.sessionId ? { sessionId: options.sessionId } : {},
|
|
27
|
+
...options.turnId ? { turnId: options.turnId } : {}
|
|
28
|
+
});
|
|
29
|
+
return {
|
|
30
|
+
text,
|
|
31
|
+
blocks: [
|
|
32
|
+
{
|
|
33
|
+
type: "section",
|
|
34
|
+
text: { type: "mrkdwn", text }
|
|
35
|
+
},
|
|
36
|
+
{
|
|
37
|
+
type: "actions",
|
|
38
|
+
elements: [
|
|
39
|
+
{
|
|
40
|
+
type: "button",
|
|
41
|
+
action_id: actionId,
|
|
42
|
+
text: { type: "plain_text", text: buttonText },
|
|
43
|
+
accessibility_label: buttonText,
|
|
44
|
+
style: "danger",
|
|
45
|
+
value
|
|
46
|
+
}
|
|
47
|
+
]
|
|
48
|
+
}
|
|
49
|
+
]
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
function encodeSlackTurnCancelButtonValue(value) {
|
|
53
|
+
return JSON.stringify(value);
|
|
54
|
+
}
|
|
55
|
+
function decodeSlackTurnCancelButtonValue(rawValue) {
|
|
56
|
+
if (typeof rawValue !== "string" || !rawValue.trim()) {
|
|
57
|
+
return void 0;
|
|
58
|
+
}
|
|
59
|
+
try {
|
|
60
|
+
const parsed = JSON.parse(rawValue);
|
|
61
|
+
const controlId = parseOptionalString(parsed.controlId);
|
|
62
|
+
if (parsed.action !== "cancel" || !controlId) {
|
|
63
|
+
return void 0;
|
|
64
|
+
}
|
|
65
|
+
const sessionId = parseOptionalString(parsed.sessionId);
|
|
66
|
+
const turnId = parseOptionalString(parsed.turnId);
|
|
67
|
+
return {
|
|
68
|
+
action: "cancel",
|
|
69
|
+
controlId,
|
|
70
|
+
...sessionId ? { sessionId } : {},
|
|
71
|
+
...turnId ? { turnId } : {}
|
|
72
|
+
};
|
|
73
|
+
} catch {
|
|
74
|
+
return void 0;
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
function parseOptionalString(value) {
|
|
78
|
+
if (typeof value !== "string") {
|
|
79
|
+
return void 0;
|
|
80
|
+
}
|
|
81
|
+
const trimmed = value.trim();
|
|
82
|
+
return trimmed || void 0;
|
|
83
|
+
}
|
|
84
|
+
function resolveSlackTurnCancelActionId(actionId) {
|
|
85
|
+
const resolved = (actionId ?? SLACK_TURN_CANCEL_ACTION_ID).trim();
|
|
86
|
+
if (!resolved) {
|
|
87
|
+
throw new Error("Slack turn cancel action id cannot be empty.");
|
|
88
|
+
}
|
|
89
|
+
return resolved;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
// src/turn-controls/action.ts
|
|
93
|
+
function registerSlackTurnCancelAction(app, options) {
|
|
94
|
+
const actionId = resolveSlackTurnCancelActionId(options.actionId);
|
|
95
|
+
app.action(
|
|
96
|
+
actionId,
|
|
97
|
+
// Bolt's action args are structurally stable, but not exported as one
|
|
98
|
+
// concise public type across all action element variants.
|
|
99
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
100
|
+
async ({ ack, body, client, logger }) => {
|
|
101
|
+
try {
|
|
102
|
+
const ackFn = ack;
|
|
103
|
+
await ackFn();
|
|
104
|
+
if (body?.type !== "block_actions" || !Array.isArray(body.actions) || body.actions.length === 0) {
|
|
105
|
+
return;
|
|
106
|
+
}
|
|
107
|
+
const action = body.actions[0];
|
|
108
|
+
if (action?.type !== "button") {
|
|
109
|
+
return;
|
|
110
|
+
}
|
|
111
|
+
const value = decodeSlackTurnCancelButtonValue(action.value);
|
|
112
|
+
if (!value) {
|
|
113
|
+
return;
|
|
114
|
+
}
|
|
115
|
+
const channelId = body.channel?.id ?? body.container?.channel_id;
|
|
116
|
+
const userId = body.user?.id;
|
|
117
|
+
const messageTs = body.message?.ts ?? body.container?.message_ts;
|
|
118
|
+
const threadTs = body.message?.thread_ts ?? body.container?.thread_ts;
|
|
119
|
+
const teamId = body.team?.id;
|
|
120
|
+
const triggerId = typeof body.trigger_id === "string" ? body.trigger_id : void 0;
|
|
121
|
+
if (!channelId || !userId || !messageTs) {
|
|
122
|
+
return;
|
|
123
|
+
}
|
|
124
|
+
const acknowledgeEphemeral = async (text) => {
|
|
125
|
+
await client.chat.postEphemeral({
|
|
126
|
+
channel: channelId,
|
|
127
|
+
user: userId,
|
|
128
|
+
...threadTs ? { thread_ts: threadTs } : { thread_ts: messageTs },
|
|
129
|
+
text
|
|
130
|
+
});
|
|
131
|
+
};
|
|
132
|
+
const deleteMessage = async () => {
|
|
133
|
+
await client.chat.delete({
|
|
134
|
+
channel: channelId,
|
|
135
|
+
ts: messageTs
|
|
136
|
+
});
|
|
137
|
+
};
|
|
138
|
+
const updateMessage = async (message) => {
|
|
139
|
+
await client.chat.update({
|
|
140
|
+
channel: channelId,
|
|
141
|
+
ts: messageTs,
|
|
142
|
+
text: message.text,
|
|
143
|
+
...message.blocks ? { blocks: message.blocks } : {}
|
|
144
|
+
});
|
|
145
|
+
};
|
|
146
|
+
await options.onCancel({
|
|
147
|
+
...value,
|
|
148
|
+
channelId,
|
|
149
|
+
userId,
|
|
150
|
+
messageTs,
|
|
151
|
+
...threadTs ? { threadTs } : {},
|
|
152
|
+
...teamId ? { teamId } : {},
|
|
153
|
+
...triggerId ? { triggerId } : {},
|
|
154
|
+
acknowledgeEphemeral,
|
|
155
|
+
deleteMessage,
|
|
156
|
+
updateMessage
|
|
157
|
+
});
|
|
158
|
+
} catch (error) {
|
|
159
|
+
logger?.error?.(
|
|
160
|
+
`[channel-slack] turn cancel action failed: ${error instanceof Error ? error.message : String(error)}`
|
|
161
|
+
);
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
);
|
|
165
|
+
return { actionId };
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
export {
|
|
169
|
+
SLACK_TURN_CANCEL_ACTION_ID,
|
|
170
|
+
createSlackTurnCancelMessage,
|
|
171
|
+
encodeSlackTurnCancelButtonValue,
|
|
172
|
+
decodeSlackTurnCancelButtonValue,
|
|
173
|
+
resolveSlackTurnCancelActionId,
|
|
174
|
+
registerSlackTurnCancelAction
|
|
175
|
+
};
|
package/dist/core.d.ts
CHANGED
|
@@ -1,4 +1,8 @@
|
|
|
1
1
|
import { S as SlackActivityInfo, b as SlackUserIdentity, a as SlackChannelType } from './activity-ByrD9Ftr.js';
|
|
2
|
+
export { S as SlackApprovalRequest, a as SlackEventInteractiveRequestHandler, b as SlackHumanInputRequest, c as SlackInteractiveMessage, d as SlackInteractiveMessageRef, e as SlackInteractiveRequest, f as SlackInteractiveRequestBaseContext, g as SlackInteractiveRequestContext, h as SlackInteractiveRequestHandler, i as SlackInteractiveRequestKind, j as SlackInteractiveResponder } from './interactive-CbKYkkc_.js';
|
|
3
|
+
export { RegisterSlackTurnCancelActionOptions, SLACK_TURN_CANCEL_ACTION_ID, SlackTurnCancelActionContext, SlackTurnCancelActionHandler, SlackTurnCancelButtonValue, SlackTurnCancelMessage, SlackTurnCancelMessageOptions, createSlackTurnCancelMessage, decodeSlackTurnCancelButtonValue, encodeSlackTurnCancelButtonValue, registerSlackTurnCancelAction, resolveSlackTurnCancelActionId } from './turn-controls/index.js';
|
|
4
|
+
import '@slack/types';
|
|
5
|
+
import '@slack/bolt';
|
|
2
6
|
|
|
3
7
|
/**
|
|
4
8
|
* Slack auth context — credentials and identifiers resolved from the inbound
|
|
@@ -175,45 +179,6 @@ interface SlackTurnPreparation {
|
|
|
175
179
|
context?: Record<string, unknown>;
|
|
176
180
|
}
|
|
177
181
|
|
|
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
182
|
/**
|
|
218
183
|
* Raw Slack event payload parsers — produce `SlackActivityInfo` from the
|
|
219
184
|
* shapes Bolt delivers for `message` and `app_mention` events.
|
|
@@ -422,4 +387,4 @@ interface SlackAmbientTurnContext extends SlackTurnRequestContext {
|
|
|
422
387
|
declare function currentSlackTurnContext(): Readonly<SlackAmbientTurnContext> | undefined;
|
|
423
388
|
declare function runWithSlackTurnContext<T>(value: SlackAmbientTurnContext, fn: () => T | Promise<T>): Promise<T>;
|
|
424
389
|
|
|
425
|
-
export { type ExtractSlackMessageTextOptions, type RawSlackActionTokenPayload, type RawSlackAppMentionPayload, type RawSlackAssistantThreadPayload, type RawSlackMessagePayload, SlackActivityInfo, type SlackAmbientTurnContext, type
|
|
390
|
+
export { type ExtractSlackMessageTextOptions, type RawSlackActionTokenPayload, type RawSlackAppMentionPayload, type RawSlackAssistantThreadPayload, type RawSlackMessagePayload, SlackActivityInfo, type SlackAmbientTurnContext, type SlackAssistantStatusUpdate, type SlackAssistantSuggestedPrompt, type SlackAssistantSuggestedPrompts, type SlackAssistantTaskDisplayMode, type SlackAssistantThreadContext, type SlackAssistantUtilities, type SlackAuthContext, SlackChannelType, type SlackChatStreamStartArgs, 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
CHANGED
|
@@ -3,7 +3,15 @@ import {
|
|
|
3
3
|
formatSlackAttributedFollowUp,
|
|
4
4
|
resolveThreadAwareSlackSessionId,
|
|
5
5
|
runWithSlackTurnContext
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-ISOMBQXE.js";
|
|
7
|
+
import {
|
|
8
|
+
SLACK_TURN_CANCEL_ACTION_ID,
|
|
9
|
+
createSlackTurnCancelMessage,
|
|
10
|
+
decodeSlackTurnCancelButtonValue,
|
|
11
|
+
encodeSlackTurnCancelButtonValue,
|
|
12
|
+
registerSlackTurnCancelAction,
|
|
13
|
+
resolveSlackTurnCancelActionId
|
|
14
|
+
} from "./chunk-3KP3CBCC.js";
|
|
7
15
|
import {
|
|
8
16
|
markdownToSlackMrkdwn,
|
|
9
17
|
resolveSlackMessageFormatter
|
|
@@ -24,7 +32,11 @@ import {
|
|
|
24
32
|
stripLeadingMentions
|
|
25
33
|
} from "./chunk-FPCE5V5Y.js";
|
|
26
34
|
export {
|
|
35
|
+
SLACK_TURN_CANCEL_ACTION_ID,
|
|
36
|
+
createSlackTurnCancelMessage,
|
|
27
37
|
currentSlackTurnContext,
|
|
38
|
+
decodeSlackTurnCancelButtonValue,
|
|
39
|
+
encodeSlackTurnCancelButtonValue,
|
|
28
40
|
extractSlackActionToken,
|
|
29
41
|
extractSlackAttachmentsText,
|
|
30
42
|
extractSlackAuthContext,
|
|
@@ -36,8 +48,10 @@ export {
|
|
|
36
48
|
markdownToSlackMrkdwn,
|
|
37
49
|
parseSlackMentionActivity,
|
|
38
50
|
parseSlackMessageActivity,
|
|
51
|
+
registerSlackTurnCancelAction,
|
|
39
52
|
resolveSlackChannelType,
|
|
40
53
|
resolveSlackMessageFormatter,
|
|
54
|
+
resolveSlackTurnCancelActionId,
|
|
41
55
|
resolveThreadAwareSlackSessionId,
|
|
42
56
|
runWithSlackTurnContext,
|
|
43
57
|
stripLeadingMentions
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,8 @@
|
|
|
1
1
|
export { S as SlackActivityInfo, a as SlackChannelType, b as SlackUserIdentity } from './activity-ByrD9Ftr.js';
|
|
2
|
-
export { ExtractSlackMessageTextOptions, RawSlackActionTokenPayload, RawSlackAppMentionPayload, RawSlackAssistantThreadPayload, RawSlackMessagePayload, SlackAmbientTurnContext,
|
|
2
|
+
export { ExtractSlackMessageTextOptions, RawSlackActionTokenPayload, RawSlackAppMentionPayload, RawSlackAssistantThreadPayload, RawSlackMessagePayload, SlackAmbientTurnContext, SlackAssistantStatusUpdate, SlackAssistantSuggestedPrompt, SlackAssistantSuggestedPrompts, SlackAssistantTaskDisplayMode, SlackAssistantThreadContext, SlackAssistantUtilities, SlackAuthContext, SlackChatStreamStartArgs, 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 { S as SlackApprovalRequest, a as SlackEventInteractiveRequestHandler, b as SlackHumanInputRequest, c as SlackInteractiveMessage, d as SlackInteractiveMessageRef, e as SlackInteractiveRequest, f as SlackInteractiveRequestBaseContext, g as SlackInteractiveRequestContext, h as SlackInteractiveRequestHandler, i as SlackInteractiveRequestKind, j as SlackInteractiveResponder } from './interactive-CbKYkkc_.js';
|
|
4
|
+
export { RegisterSlackTurnCancelActionOptions, SLACK_TURN_CANCEL_ACTION_ID, SlackTurnCancelActionContext, SlackTurnCancelActionHandler, SlackTurnCancelButtonValue, SlackTurnCancelMessage, SlackTurnCancelMessageOptions, createSlackTurnCancelMessage, decodeSlackTurnCancelButtonValue, encodeSlackTurnCancelButtonValue, registerSlackTurnCancelAction, resolveSlackTurnCancelActionId } from './turn-controls/index.js';
|
|
3
5
|
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
6
|
export { L as Logger } from './logging-Bl3HfcC8.js';
|
|
7
|
+
import '@slack/types';
|
|
8
|
+
import '@slack/bolt';
|
package/dist/index.js
CHANGED
|
@@ -20,7 +20,15 @@ import {
|
|
|
20
20
|
formatSlackAttributedFollowUp,
|
|
21
21
|
resolveThreadAwareSlackSessionId,
|
|
22
22
|
runWithSlackTurnContext
|
|
23
|
-
} from "./chunk-
|
|
23
|
+
} from "./chunk-ISOMBQXE.js";
|
|
24
|
+
import {
|
|
25
|
+
SLACK_TURN_CANCEL_ACTION_ID,
|
|
26
|
+
createSlackTurnCancelMessage,
|
|
27
|
+
decodeSlackTurnCancelButtonValue,
|
|
28
|
+
encodeSlackTurnCancelButtonValue,
|
|
29
|
+
registerSlackTurnCancelAction,
|
|
30
|
+
resolveSlackTurnCancelActionId
|
|
31
|
+
} from "./chunk-3KP3CBCC.js";
|
|
24
32
|
import {
|
|
25
33
|
markdownToSlackMrkdwn,
|
|
26
34
|
resolveSlackMessageFormatter
|
|
@@ -41,6 +49,7 @@ import {
|
|
|
41
49
|
stripLeadingMentions
|
|
42
50
|
} from "./chunk-FPCE5V5Y.js";
|
|
43
51
|
export {
|
|
52
|
+
SLACK_TURN_CANCEL_ACTION_ID,
|
|
44
53
|
createAsyncSlackMessagePolicyResolver,
|
|
45
54
|
createAsyncSlackThreadAwareMessagePolicyResolver,
|
|
46
55
|
createInMemorySlackMessagePolicyStateStore,
|
|
@@ -50,7 +59,10 @@ export {
|
|
|
50
59
|
createSlackMessagePolicyMessageKey,
|
|
51
60
|
createSlackMessagePolicyResolver,
|
|
52
61
|
createSlackMessagePolicyThreadKey,
|
|
62
|
+
createSlackTurnCancelMessage,
|
|
53
63
|
currentSlackTurnContext,
|
|
64
|
+
decodeSlackTurnCancelButtonValue,
|
|
65
|
+
encodeSlackTurnCancelButtonValue,
|
|
54
66
|
extractSlackActionToken,
|
|
55
67
|
extractSlackAttachmentsText,
|
|
56
68
|
extractSlackAuthContext,
|
|
@@ -66,9 +78,11 @@ export {
|
|
|
66
78
|
parseSlackMessageActivity,
|
|
67
79
|
prunePostgresSlackMessagePolicyState,
|
|
68
80
|
prunePostgresSlackThreadParticipationState,
|
|
81
|
+
registerSlackTurnCancelAction,
|
|
69
82
|
resolveSlackChannelType,
|
|
70
83
|
resolveSlackMessageFormatter,
|
|
71
84
|
resolveSlackThreadParticipationEligibility,
|
|
85
|
+
resolveSlackTurnCancelActionId,
|
|
72
86
|
resolveThreadAwareSlackSessionId,
|
|
73
87
|
runWithSlackTurnContext,
|
|
74
88
|
shouldRegisterSlackPassiveChannelMessages,
|
|
@@ -0,0 +1,154 @@
|
|
|
1
|
+
import { g as SlackInteractiveRequestContext } from '../interactive-CbKYkkc_.js';
|
|
2
|
+
export { c as SlackInteractiveMessage, d as SlackInteractiveMessageRef, f as SlackInteractiveRequestBaseContext, i as SlackInteractiveRequestKind, j as SlackInteractiveResponder } from '../interactive-CbKYkkc_.js';
|
|
3
|
+
import { View } from '@slack/types';
|
|
4
|
+
import '../activity-ByrD9Ftr.js';
|
|
5
|
+
|
|
6
|
+
type SlackInteractiveRequestStatus = "pending" | "resolved";
|
|
7
|
+
type SlackInteractiveApprovalAction = "allow" | "deny" | "remember";
|
|
8
|
+
type SlackInteractiveHumanInputResponse = {
|
|
9
|
+
kind: "text";
|
|
10
|
+
text: string;
|
|
11
|
+
} | {
|
|
12
|
+
kind: "confirm";
|
|
13
|
+
confirmed: boolean;
|
|
14
|
+
text: string;
|
|
15
|
+
} | {
|
|
16
|
+
kind: "choice";
|
|
17
|
+
selected: string[];
|
|
18
|
+
text: string;
|
|
19
|
+
};
|
|
20
|
+
interface SlackInteractiveApprovalRequest {
|
|
21
|
+
id: string;
|
|
22
|
+
tool: string;
|
|
23
|
+
args: unknown;
|
|
24
|
+
description: string;
|
|
25
|
+
risk: string;
|
|
26
|
+
rememberScopes?: string[];
|
|
27
|
+
defaultRememberScope?: string;
|
|
28
|
+
}
|
|
29
|
+
interface SlackInteractiveHumanInputOption {
|
|
30
|
+
label: string;
|
|
31
|
+
value?: string;
|
|
32
|
+
description?: string;
|
|
33
|
+
}
|
|
34
|
+
interface SlackInteractiveHumanInputRequest {
|
|
35
|
+
id: string;
|
|
36
|
+
kind: "text" | "confirm" | "choice";
|
|
37
|
+
title: string;
|
|
38
|
+
question: string;
|
|
39
|
+
options?: SlackInteractiveHumanInputOption[];
|
|
40
|
+
allowMultiple?: boolean;
|
|
41
|
+
placeholder?: string;
|
|
42
|
+
confirmLabel?: string;
|
|
43
|
+
denyLabel?: string;
|
|
44
|
+
}
|
|
45
|
+
type SlackInteractiveStoredRequest = SlackInteractiveApprovalRequest | SlackInteractiveHumanInputRequest;
|
|
46
|
+
type SlackInteractiveResolution = {
|
|
47
|
+
kind: "approval";
|
|
48
|
+
action: SlackInteractiveApprovalAction;
|
|
49
|
+
feedback?: string;
|
|
50
|
+
rememberScope?: string;
|
|
51
|
+
} | {
|
|
52
|
+
kind: "human-input";
|
|
53
|
+
response: SlackInteractiveHumanInputResponse;
|
|
54
|
+
};
|
|
55
|
+
interface SlackInteractiveMessageTarget {
|
|
56
|
+
channel: string;
|
|
57
|
+
ts: string;
|
|
58
|
+
threadTs?: string;
|
|
59
|
+
userId: string;
|
|
60
|
+
teamId?: string;
|
|
61
|
+
}
|
|
62
|
+
interface SlackInteractiveRequestRecord {
|
|
63
|
+
id: string;
|
|
64
|
+
kind: SlackInteractiveResolution["kind"];
|
|
65
|
+
request: SlackInteractiveStoredRequest;
|
|
66
|
+
status: SlackInteractiveRequestStatus;
|
|
67
|
+
createdAt: string;
|
|
68
|
+
updatedAt: string;
|
|
69
|
+
target?: SlackInteractiveMessageTarget;
|
|
70
|
+
resolution?: SlackInteractiveResolution;
|
|
71
|
+
}
|
|
72
|
+
interface SlackInteractiveRequestStore {
|
|
73
|
+
get(requestId: string): Promise<SlackInteractiveRequestRecord | undefined>;
|
|
74
|
+
upsert(record: SlackInteractiveRequestRecord): Promise<SlackInteractiveRequestRecord>;
|
|
75
|
+
attachTarget(requestId: string, target: SlackInteractiveMessageTarget): Promise<SlackInteractiveRequestRecord | undefined>;
|
|
76
|
+
resolve(requestId: string, resolution: SlackInteractiveResolution): Promise<SlackInteractiveRequestRecord | undefined>;
|
|
77
|
+
delete(requestId: string): Promise<void>;
|
|
78
|
+
}
|
|
79
|
+
interface SlackInteractiveActionIds {
|
|
80
|
+
approvalAllow: string;
|
|
81
|
+
approvalDeny: string;
|
|
82
|
+
approvalRemember: string;
|
|
83
|
+
humanConfirm: string;
|
|
84
|
+
humanDeny: string;
|
|
85
|
+
humanOpen: string;
|
|
86
|
+
humanSubmit: string;
|
|
87
|
+
}
|
|
88
|
+
interface SlackInteractiveActor {
|
|
89
|
+
userId: string;
|
|
90
|
+
teamId?: string;
|
|
91
|
+
}
|
|
92
|
+
type SlackInteractiveRequestHandler = (context: SlackInteractiveRequestContext) => boolean | void | Promise<boolean | void>;
|
|
93
|
+
|
|
94
|
+
declare function buildApprovalRequestMessage(request: SlackInteractiveApprovalRequest, actionIds: SlackInteractiveActionIds): {
|
|
95
|
+
text: string;
|
|
96
|
+
blocks: unknown[];
|
|
97
|
+
};
|
|
98
|
+
declare function buildHumanInputRequestMessage(request: SlackInteractiveHumanInputRequest, actionIds: SlackInteractiveActionIds): {
|
|
99
|
+
text: string;
|
|
100
|
+
blocks: unknown[];
|
|
101
|
+
};
|
|
102
|
+
declare function buildResolvedMessage(label: string, resolution: SlackInteractiveResolution): {
|
|
103
|
+
text: string;
|
|
104
|
+
blocks: unknown[];
|
|
105
|
+
};
|
|
106
|
+
declare function buildHumanInputModal(request: SlackInteractiveHumanInputRequest, actionIds: SlackInteractiveActionIds): View;
|
|
107
|
+
declare function encodeActionValue(payload: Record<string, unknown>): string;
|
|
108
|
+
declare function decodeActionValue(value: unknown): Record<string, unknown>;
|
|
109
|
+
|
|
110
|
+
declare function createInMemorySlackInteractiveRequestStore(): SlackInteractiveRequestStore;
|
|
111
|
+
declare function nowIso(): string;
|
|
112
|
+
declare function cloneRecord(record: SlackInteractiveRequestRecord): SlackInteractiveRequestRecord;
|
|
113
|
+
|
|
114
|
+
interface SlackInteractivePostgresClient {
|
|
115
|
+
end?: () => Promise<void>;
|
|
116
|
+
query<T = unknown>(sql: string, values?: readonly unknown[]): Promise<{
|
|
117
|
+
rows: T[];
|
|
118
|
+
rowCount?: number | null;
|
|
119
|
+
}>;
|
|
120
|
+
}
|
|
121
|
+
interface PostgresSlackInteractiveRequestStoreOptions {
|
|
122
|
+
client?: SlackInteractivePostgresClient;
|
|
123
|
+
connectionString?: string;
|
|
124
|
+
ensureSchema?: boolean;
|
|
125
|
+
onPruneError?: (error: unknown) => void;
|
|
126
|
+
pruneBatchSize?: number;
|
|
127
|
+
pruneIntervalMs?: number;
|
|
128
|
+
retentionMs?: number;
|
|
129
|
+
schema?: string;
|
|
130
|
+
tableName?: string;
|
|
131
|
+
}
|
|
132
|
+
interface PostgresSlackInteractiveRequestStore extends SlackInteractiveRequestStore {
|
|
133
|
+
close(): Promise<void>;
|
|
134
|
+
prune(): Promise<PostgresSlackInteractiveRequestPruneResult>;
|
|
135
|
+
}
|
|
136
|
+
interface PostgresSlackInteractiveRequestPruneResult {
|
|
137
|
+
deleted: number;
|
|
138
|
+
}
|
|
139
|
+
declare function createPostgresSlackInteractiveRequestStore({ client, connectionString, ensureSchema, onPruneError, pruneBatchSize, pruneIntervalMs, retentionMs, schema, tableName, }: PostgresSlackInteractiveRequestStoreOptions): PostgresSlackInteractiveRequestStore;
|
|
140
|
+
declare function initializePostgresSlackInteractiveRequestStore({ client, ensureSchema, schema, tableName, }: {
|
|
141
|
+
client: SlackInteractivePostgresClient;
|
|
142
|
+
ensureSchema?: boolean;
|
|
143
|
+
schema?: string;
|
|
144
|
+
tableName?: string;
|
|
145
|
+
}): Promise<void>;
|
|
146
|
+
declare function prunePostgresSlackInteractiveRequestStore({ client, pruneBatchSize, retentionMs, schema, tableName, }: {
|
|
147
|
+
client: SlackInteractivePostgresClient;
|
|
148
|
+
pruneBatchSize?: number;
|
|
149
|
+
retentionMs?: number;
|
|
150
|
+
schema?: string;
|
|
151
|
+
tableName?: string;
|
|
152
|
+
}): Promise<PostgresSlackInteractiveRequestPruneResult>;
|
|
153
|
+
|
|
154
|
+
export { type PostgresSlackInteractiveRequestPruneResult, type PostgresSlackInteractiveRequestStore, type PostgresSlackInteractiveRequestStoreOptions, type SlackInteractiveActionIds, type SlackInteractiveActor, type SlackInteractiveApprovalAction, type SlackInteractiveApprovalRequest, type SlackInteractiveHumanInputOption, type SlackInteractiveHumanInputRequest, type SlackInteractiveHumanInputResponse, type SlackInteractiveMessageTarget, type SlackInteractivePostgresClient, SlackInteractiveRequestContext, type SlackInteractiveRequestHandler, type SlackInteractiveRequestRecord, type SlackInteractiveRequestStatus, type SlackInteractiveRequestStore, type SlackInteractiveResolution, type SlackInteractiveStoredRequest, buildApprovalRequestMessage, buildHumanInputModal, buildHumanInputRequestMessage, buildResolvedMessage, cloneRecord, createInMemorySlackInteractiveRequestStore, createPostgresSlackInteractiveRequestStore, decodeActionValue, encodeActionValue, initializePostgresSlackInteractiveRequestStore, nowIso, prunePostgresSlackInteractiveRequestStore };
|