@cuylabs/channel-slack 0.6.0 → 0.8.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/dist/app-home.js +7 -2
- package/dist/chunk-3KP3CBCC.js +175 -0
- package/dist/chunk-IRFKUPJN.js +235 -0
- package/dist/core.d.ts +3 -0
- package/dist/core.js +15 -1
- package/dist/feedback/index.js +5 -7
- package/dist/index.d.ts +3 -0
- package/dist/index.js +15 -1
- package/dist/setup/index.d.ts +1 -1
- package/dist/setup/index.js +3 -0
- package/dist/transports/index.js +3 -3
- package/dist/turn-controls/index.d.ts +51 -0
- package/dist/turn-controls/index.js +16 -0
- package/dist/views/index.d.ts +98 -0
- package/dist/views/index.js +22 -0
- package/docs/README.md +1 -0
- package/docs/concepts/views.md +46 -0
- package/docs/reference/exports.md +18 -17
- package/docs/reference/source-layout.md +1 -0
- package/package.json +13 -3
- /package/dist/{chunk-X4WBBBYM.js → chunk-ISOMBQXE.js} +0 -0
package/dist/app-home.js
CHANGED
|
@@ -1,3 +1,7 @@
|
|
|
1
|
+
import {
|
|
2
|
+
publishSlackHomeView
|
|
3
|
+
} from "./chunk-IRFKUPJN.js";
|
|
4
|
+
|
|
1
5
|
// src/app-home.ts
|
|
2
6
|
function installSlackAppHome({
|
|
3
7
|
boltApp,
|
|
@@ -7,8 +11,9 @@ function installSlackAppHome({
|
|
|
7
11
|
boltApp.event("app_home_opened", async ({ event, client }) => {
|
|
8
12
|
const homeEvent = event;
|
|
9
13
|
try {
|
|
10
|
-
await
|
|
11
|
-
|
|
14
|
+
await publishSlackHomeView({
|
|
15
|
+
client,
|
|
16
|
+
userId: homeEvent.user,
|
|
12
17
|
view: await buildView({ event: homeEvent })
|
|
13
18
|
});
|
|
14
19
|
logger?.debug?.("Slack App Home published", {
|
|
@@ -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
|
+
};
|
|
@@ -0,0 +1,235 @@
|
|
|
1
|
+
// src/views/client.ts
|
|
2
|
+
async function openSlackModal({
|
|
3
|
+
client,
|
|
4
|
+
triggerId,
|
|
5
|
+
view,
|
|
6
|
+
token
|
|
7
|
+
}) {
|
|
8
|
+
return await requireViewsMethod(
|
|
9
|
+
client,
|
|
10
|
+
"open"
|
|
11
|
+
)({
|
|
12
|
+
...tokenArgs(token),
|
|
13
|
+
trigger_id: requireTrimmed(triggerId, "triggerId"),
|
|
14
|
+
view
|
|
15
|
+
});
|
|
16
|
+
}
|
|
17
|
+
async function pushSlackModal({
|
|
18
|
+
client,
|
|
19
|
+
triggerId,
|
|
20
|
+
view,
|
|
21
|
+
token
|
|
22
|
+
}) {
|
|
23
|
+
return await requireViewsMethod(
|
|
24
|
+
client,
|
|
25
|
+
"push"
|
|
26
|
+
)({
|
|
27
|
+
...tokenArgs(token),
|
|
28
|
+
trigger_id: requireTrimmed(triggerId, "triggerId"),
|
|
29
|
+
view
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
async function updateSlackView({
|
|
33
|
+
client,
|
|
34
|
+
view,
|
|
35
|
+
viewId,
|
|
36
|
+
externalId,
|
|
37
|
+
hash,
|
|
38
|
+
token
|
|
39
|
+
}) {
|
|
40
|
+
const normalizedViewId = trimOptional(viewId);
|
|
41
|
+
const normalizedExternalId = trimOptional(externalId);
|
|
42
|
+
if (!normalizedViewId && !normalizedExternalId) {
|
|
43
|
+
throw new Error("updateSlackView requires viewId or externalId.");
|
|
44
|
+
}
|
|
45
|
+
return await requireViewsMethod(
|
|
46
|
+
client,
|
|
47
|
+
"update"
|
|
48
|
+
)({
|
|
49
|
+
...tokenArgs(token),
|
|
50
|
+
...normalizedViewId ? { view_id: normalizedViewId } : {},
|
|
51
|
+
...normalizedExternalId ? { external_id: normalizedExternalId } : {},
|
|
52
|
+
...trimOptional(hash) ? { hash: hash?.trim() } : {},
|
|
53
|
+
view
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
async function publishSlackHomeView({
|
|
57
|
+
client,
|
|
58
|
+
userId,
|
|
59
|
+
view,
|
|
60
|
+
hash,
|
|
61
|
+
token
|
|
62
|
+
}) {
|
|
63
|
+
return await requireViewsMethod(
|
|
64
|
+
client,
|
|
65
|
+
"publish"
|
|
66
|
+
)({
|
|
67
|
+
...tokenArgs(token),
|
|
68
|
+
user_id: requireTrimmed(userId, "userId"),
|
|
69
|
+
...trimOptional(hash) ? { hash: hash?.trim() } : {},
|
|
70
|
+
view
|
|
71
|
+
});
|
|
72
|
+
}
|
|
73
|
+
function requireViewsMethod(client, methodName) {
|
|
74
|
+
const method = client.views?.[methodName];
|
|
75
|
+
if (typeof method !== "function") {
|
|
76
|
+
throw new Error(`Slack client does not expose views.${methodName}.`);
|
|
77
|
+
}
|
|
78
|
+
return method.bind(client.views);
|
|
79
|
+
}
|
|
80
|
+
function requireTrimmed(value, label) {
|
|
81
|
+
const trimmed = value.trim();
|
|
82
|
+
if (!trimmed) {
|
|
83
|
+
throw new Error(`${label} is required.`);
|
|
84
|
+
}
|
|
85
|
+
return trimmed;
|
|
86
|
+
}
|
|
87
|
+
function trimOptional(value) {
|
|
88
|
+
const trimmed = value?.trim();
|
|
89
|
+
return trimmed ? trimmed : void 0;
|
|
90
|
+
}
|
|
91
|
+
function tokenArgs(token) {
|
|
92
|
+
const trimmed = token?.trim();
|
|
93
|
+
return trimmed ? { token: trimmed } : {};
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
// src/views/metadata.ts
|
|
97
|
+
var SLACK_VIEW_PRIVATE_METADATA_MAX_CHARS = 3e3;
|
|
98
|
+
function encodeSlackViewPrivateMetadata(value) {
|
|
99
|
+
if (value === void 0 || value === null) {
|
|
100
|
+
return "";
|
|
101
|
+
}
|
|
102
|
+
const encoded = typeof value === "string" ? value : JSON.stringify(value);
|
|
103
|
+
if (encoded.length > SLACK_VIEW_PRIVATE_METADATA_MAX_CHARS) {
|
|
104
|
+
throw new Error(
|
|
105
|
+
`Slack view private_metadata exceeds ${SLACK_VIEW_PRIVATE_METADATA_MAX_CHARS} characters.`
|
|
106
|
+
);
|
|
107
|
+
}
|
|
108
|
+
return encoded;
|
|
109
|
+
}
|
|
110
|
+
function decodeSlackViewPrivateMetadata(privateMetadata) {
|
|
111
|
+
const normalized = privateMetadata?.trim();
|
|
112
|
+
if (!normalized) {
|
|
113
|
+
return void 0;
|
|
114
|
+
}
|
|
115
|
+
try {
|
|
116
|
+
return JSON.parse(normalized);
|
|
117
|
+
} catch {
|
|
118
|
+
return normalized;
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
function readSlackViewPrivateMetadata(view) {
|
|
122
|
+
return decodeSlackViewPrivateMetadata(view.private_metadata);
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
// src/views/workflow.ts
|
|
126
|
+
function registerSlackViewWorkflow({
|
|
127
|
+
boltApp,
|
|
128
|
+
callbackId,
|
|
129
|
+
decodePrivateMetadata,
|
|
130
|
+
onSubmission,
|
|
131
|
+
onClose,
|
|
132
|
+
onError
|
|
133
|
+
}) {
|
|
134
|
+
if (onSubmission) {
|
|
135
|
+
boltApp.view(
|
|
136
|
+
{ callback_id: callbackId, type: "view_submission" },
|
|
137
|
+
// Bolt's listener args are structurally stable, but the exact generic
|
|
138
|
+
// narrows differ between view_submission and view_closed.
|
|
139
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
140
|
+
async ({ ack, body, client, view }) => {
|
|
141
|
+
const baseContext = createWorkflowContext({
|
|
142
|
+
body,
|
|
143
|
+
client,
|
|
144
|
+
view
|
|
145
|
+
});
|
|
146
|
+
try {
|
|
147
|
+
const metadata = resolveMetadata(
|
|
148
|
+
decodePrivateMetadata,
|
|
149
|
+
view,
|
|
150
|
+
baseContext
|
|
151
|
+
);
|
|
152
|
+
const response = await onSubmission({
|
|
153
|
+
...baseContext,
|
|
154
|
+
metadata
|
|
155
|
+
});
|
|
156
|
+
await ack(response);
|
|
157
|
+
} catch (error) {
|
|
158
|
+
try {
|
|
159
|
+
await ack();
|
|
160
|
+
} catch {
|
|
161
|
+
}
|
|
162
|
+
await onError?.(error, baseContext);
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
);
|
|
166
|
+
}
|
|
167
|
+
if (onClose) {
|
|
168
|
+
boltApp.view(
|
|
169
|
+
{ callback_id: callbackId, type: "view_closed" },
|
|
170
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
171
|
+
async ({ ack, body, client, view }) => {
|
|
172
|
+
const baseContext = createWorkflowContext({
|
|
173
|
+
body,
|
|
174
|
+
client,
|
|
175
|
+
view
|
|
176
|
+
});
|
|
177
|
+
await ack();
|
|
178
|
+
try {
|
|
179
|
+
const metadata = resolveMetadata(
|
|
180
|
+
decodePrivateMetadata,
|
|
181
|
+
view,
|
|
182
|
+
baseContext
|
|
183
|
+
);
|
|
184
|
+
await onClose({
|
|
185
|
+
...baseContext,
|
|
186
|
+
metadata
|
|
187
|
+
});
|
|
188
|
+
} catch (error) {
|
|
189
|
+
await onError?.(error, baseContext);
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
);
|
|
193
|
+
}
|
|
194
|
+
return { callbackId };
|
|
195
|
+
}
|
|
196
|
+
function createWorkflowContext({
|
|
197
|
+
body,
|
|
198
|
+
client,
|
|
199
|
+
view
|
|
200
|
+
}) {
|
|
201
|
+
const bodyRecord = isRecord(body) ? body : {};
|
|
202
|
+
const user = isRecord(bodyRecord.user) ? bodyRecord.user : {};
|
|
203
|
+
const team = isRecord(bodyRecord.team) ? bodyRecord.team : {};
|
|
204
|
+
const enterprise = isRecord(bodyRecord.enterprise) ? bodyRecord.enterprise : {};
|
|
205
|
+
return {
|
|
206
|
+
body,
|
|
207
|
+
client,
|
|
208
|
+
view,
|
|
209
|
+
...typeof view.callback_id === "string" ? { callbackId: view.callback_id } : {},
|
|
210
|
+
...typeof bodyRecord.trigger_id === "string" ? { triggerId: bodyRecord.trigger_id } : {},
|
|
211
|
+
actor: {
|
|
212
|
+
...typeof user.id === "string" ? { userId: user.id } : {},
|
|
213
|
+
...typeof team.id === "string" ? { teamId: team.id } : {},
|
|
214
|
+
...typeof enterprise.id === "string" ? { enterpriseId: enterprise.id } : {}
|
|
215
|
+
}
|
|
216
|
+
};
|
|
217
|
+
}
|
|
218
|
+
function resolveMetadata(decodePrivateMetadata, view, context) {
|
|
219
|
+
return decodePrivateMetadata ? decodePrivateMetadata(view.private_metadata, context) : decodeSlackViewPrivateMetadata(view.private_metadata);
|
|
220
|
+
}
|
|
221
|
+
function isRecord(value) {
|
|
222
|
+
return typeof value === "object" && value !== null;
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
export {
|
|
226
|
+
openSlackModal,
|
|
227
|
+
pushSlackModal,
|
|
228
|
+
updateSlackView,
|
|
229
|
+
publishSlackHomeView,
|
|
230
|
+
SLACK_VIEW_PRIVATE_METADATA_MAX_CHARS,
|
|
231
|
+
encodeSlackViewPrivateMetadata,
|
|
232
|
+
decodeSlackViewPrivateMetadata,
|
|
233
|
+
readSlackViewPrivateMetadata,
|
|
234
|
+
registerSlackViewWorkflow
|
|
235
|
+
};
|
package/dist/core.d.ts
CHANGED
|
@@ -1,4 +1,7 @@
|
|
|
1
1
|
import { S as SlackActivityInfo, b as SlackUserIdentity, a as SlackChannelType } from './activity-ByrD9Ftr.js';
|
|
2
|
+
export { RegisterSlackTurnCancelActionOptions, SLACK_TURN_CANCEL_ACTION_ID, SlackTurnCancelActionContext, SlackTurnCancelActionHandler, SlackTurnCancelButtonValue, SlackTurnCancelMessage, SlackTurnCancelMessageOptions, createSlackTurnCancelMessage, decodeSlackTurnCancelButtonValue, encodeSlackTurnCancelButtonValue, registerSlackTurnCancelAction, resolveSlackTurnCancelActionId } from './turn-controls/index.js';
|
|
3
|
+
import '@slack/types';
|
|
4
|
+
import '@slack/bolt';
|
|
2
5
|
|
|
3
6
|
/**
|
|
4
7
|
* Slack auth context — credentials and identifiers resolved from the inbound
|
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/feedback/index.js
CHANGED
|
@@ -1,3 +1,7 @@
|
|
|
1
|
+
import {
|
|
2
|
+
openSlackModal
|
|
3
|
+
} from "../chunk-IRFKUPJN.js";
|
|
4
|
+
|
|
1
5
|
// src/feedback/block.ts
|
|
2
6
|
var SLACK_FEEDBACK_ACTION_ID = "agent_feedback";
|
|
3
7
|
function createSlackFeedbackBlock(options = {}) {
|
|
@@ -76,13 +80,7 @@ function registerSlackFeedbackAction(app, options) {
|
|
|
76
80
|
"Slack feedback payload did not include trigger_id."
|
|
77
81
|
);
|
|
78
82
|
}
|
|
79
|
-
|
|
80
|
-
throw new Error("Slack client does not expose views.open.");
|
|
81
|
-
}
|
|
82
|
-
await client.views.open({
|
|
83
|
-
trigger_id: triggerId,
|
|
84
|
-
view
|
|
85
|
-
});
|
|
83
|
+
await openSlackModal({ client, triggerId, view });
|
|
86
84
|
};
|
|
87
85
|
const acknowledgeEphemeral = async (text) => {
|
|
88
86
|
await client.chat.postEphemeral({
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,7 @@
|
|
|
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 { RegisterSlackTurnCancelActionOptions, SLACK_TURN_CANCEL_ACTION_ID, SlackTurnCancelActionContext, SlackTurnCancelActionHandler, SlackTurnCancelButtonValue, SlackTurnCancelMessage, SlackTurnCancelMessageOptions, createSlackTurnCancelMessage, decodeSlackTurnCancelButtonValue, encodeSlackTurnCancelButtonValue, registerSlackTurnCancelAction, resolveSlackTurnCancelActionId } from './turn-controls/index.js';
|
|
3
4
|
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
5
|
export { L as Logger } from './logging-Bl3HfcC8.js';
|
|
6
|
+
import '@slack/types';
|
|
7
|
+
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,
|
package/dist/setup/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { I as InspectSlackConnectionOptions, f as SlackDiagnosticsClient, c as SlackConnectionInspection } from '../inspect-BpY5JA0K.js';
|
|
2
2
|
|
|
3
|
-
type SlackSetupFeature = "assistant" | "app-mentions" | "direct-messages" | "channel-messages" | "slash-commands" | "shortcuts" | "artifacts" | "canvas-artifacts" | "history" | "interactivity" | "feedback" | "user-profiles" | "user-emails" | "workspace-search";
|
|
3
|
+
type SlackSetupFeature = "assistant" | "app-mentions" | "direct-messages" | "channel-messages" | "slash-commands" | "shortcuts" | "artifacts" | "canvas-artifacts" | "history" | "interactivity" | "views" | "feedback" | "user-profiles" | "user-emails" | "workspace-search";
|
|
4
4
|
type SlackSetupFeaturePreset = "assistant" | "channel-adapter" | "agent-app";
|
|
5
5
|
type SlackSetupTransport = "http" | "socket";
|
|
6
6
|
interface SlackSetupEnvironmentVariable {
|
package/dist/setup/index.js
CHANGED
package/dist/transports/index.js
CHANGED
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
import {
|
|
2
|
+
createSlackBoltApp
|
|
3
|
+
} from "../chunk-QJYCHWN6.js";
|
|
1
4
|
import {
|
|
2
5
|
acquireSlackSocketModePostgresLock,
|
|
3
6
|
acquireSlackSocketModeProcessLock,
|
|
@@ -7,9 +10,6 @@ import {
|
|
|
7
10
|
createSlackSocketModeRuntime,
|
|
8
11
|
redactSlackSocketModeLogValue
|
|
9
12
|
} from "../chunk-73QXT7MA.js";
|
|
10
|
-
import {
|
|
11
|
-
createSlackBoltApp
|
|
12
|
-
} from "../chunk-QJYCHWN6.js";
|
|
13
13
|
import "../chunk-S3SWPYXJ.js";
|
|
14
14
|
export {
|
|
15
15
|
acquireSlackSocketModePostgresLock,
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { SectionBlock, ActionsBlock, KnownBlock } from '@slack/types';
|
|
2
|
+
import { App } from '@slack/bolt';
|
|
3
|
+
|
|
4
|
+
declare const SLACK_TURN_CANCEL_ACTION_ID = "agent_turn_cancel";
|
|
5
|
+
interface SlackTurnCancelButtonValue {
|
|
6
|
+
action: "cancel";
|
|
7
|
+
controlId: string;
|
|
8
|
+
sessionId?: string;
|
|
9
|
+
turnId?: string;
|
|
10
|
+
}
|
|
11
|
+
interface SlackTurnCancelMessageOptions {
|
|
12
|
+
controlId: string;
|
|
13
|
+
actionId?: string;
|
|
14
|
+
buttonText?: string;
|
|
15
|
+
messageText?: string;
|
|
16
|
+
sessionId?: string;
|
|
17
|
+
turnId?: string;
|
|
18
|
+
}
|
|
19
|
+
interface SlackTurnCancelMessage {
|
|
20
|
+
text: string;
|
|
21
|
+
blocks: [SectionBlock, ActionsBlock];
|
|
22
|
+
}
|
|
23
|
+
declare function createSlackTurnCancelMessage(options: SlackTurnCancelMessageOptions): SlackTurnCancelMessage;
|
|
24
|
+
declare function encodeSlackTurnCancelButtonValue(value: SlackTurnCancelButtonValue): string;
|
|
25
|
+
declare function decodeSlackTurnCancelButtonValue(rawValue: unknown): SlackTurnCancelButtonValue | undefined;
|
|
26
|
+
declare function resolveSlackTurnCancelActionId(actionId?: string): string;
|
|
27
|
+
|
|
28
|
+
interface SlackTurnCancelActionContext extends SlackTurnCancelButtonValue {
|
|
29
|
+
channelId: string;
|
|
30
|
+
userId: string;
|
|
31
|
+
messageTs: string;
|
|
32
|
+
threadTs?: string;
|
|
33
|
+
teamId?: string;
|
|
34
|
+
triggerId?: string;
|
|
35
|
+
acknowledgeEphemeral: (text: string) => Promise<void>;
|
|
36
|
+
deleteMessage: () => Promise<void>;
|
|
37
|
+
updateMessage: (message: {
|
|
38
|
+
text: string;
|
|
39
|
+
blocks?: KnownBlock[];
|
|
40
|
+
}) => Promise<void>;
|
|
41
|
+
}
|
|
42
|
+
type SlackTurnCancelActionHandler = (context: SlackTurnCancelActionContext) => void | Promise<void>;
|
|
43
|
+
interface RegisterSlackTurnCancelActionOptions {
|
|
44
|
+
actionId?: string;
|
|
45
|
+
onCancel: SlackTurnCancelActionHandler;
|
|
46
|
+
}
|
|
47
|
+
declare function registerSlackTurnCancelAction(app: App, options: RegisterSlackTurnCancelActionOptions): {
|
|
48
|
+
actionId: string;
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
export { type RegisterSlackTurnCancelActionOptions, SLACK_TURN_CANCEL_ACTION_ID, type SlackTurnCancelActionContext, type SlackTurnCancelActionHandler, type SlackTurnCancelButtonValue, type SlackTurnCancelMessage, type SlackTurnCancelMessageOptions, createSlackTurnCancelMessage, decodeSlackTurnCancelButtonValue, encodeSlackTurnCancelButtonValue, registerSlackTurnCancelAction, resolveSlackTurnCancelActionId };
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import {
|
|
2
|
+
SLACK_TURN_CANCEL_ACTION_ID,
|
|
3
|
+
createSlackTurnCancelMessage,
|
|
4
|
+
decodeSlackTurnCancelButtonValue,
|
|
5
|
+
encodeSlackTurnCancelButtonValue,
|
|
6
|
+
registerSlackTurnCancelAction,
|
|
7
|
+
resolveSlackTurnCancelActionId
|
|
8
|
+
} from "../chunk-3KP3CBCC.js";
|
|
9
|
+
export {
|
|
10
|
+
SLACK_TURN_CANCEL_ACTION_ID,
|
|
11
|
+
createSlackTurnCancelMessage,
|
|
12
|
+
decodeSlackTurnCancelButtonValue,
|
|
13
|
+
encodeSlackTurnCancelButtonValue,
|
|
14
|
+
registerSlackTurnCancelAction,
|
|
15
|
+
resolveSlackTurnCancelActionId
|
|
16
|
+
};
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
import { App } from '@slack/bolt';
|
|
2
|
+
import { View, HomeView } from '@slack/types';
|
|
3
|
+
|
|
4
|
+
type SlackViewCallbackId = string | RegExp;
|
|
5
|
+
interface SlackViewApiResponse {
|
|
6
|
+
ok?: boolean;
|
|
7
|
+
view?: unknown;
|
|
8
|
+
[key: string]: unknown;
|
|
9
|
+
}
|
|
10
|
+
interface SlackViewsClient {
|
|
11
|
+
views?: {
|
|
12
|
+
open?: unknown;
|
|
13
|
+
push?: unknown;
|
|
14
|
+
update?: unknown;
|
|
15
|
+
publish?: unknown;
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
interface OpenSlackModalOptions {
|
|
19
|
+
client: SlackViewsClient;
|
|
20
|
+
triggerId: string;
|
|
21
|
+
view: View;
|
|
22
|
+
token?: string;
|
|
23
|
+
}
|
|
24
|
+
interface PushSlackModalOptions {
|
|
25
|
+
client: SlackViewsClient;
|
|
26
|
+
triggerId: string;
|
|
27
|
+
view: View;
|
|
28
|
+
token?: string;
|
|
29
|
+
}
|
|
30
|
+
interface UpdateSlackViewOptions {
|
|
31
|
+
client: SlackViewsClient;
|
|
32
|
+
view: View;
|
|
33
|
+
viewId?: string;
|
|
34
|
+
externalId?: string;
|
|
35
|
+
hash?: string;
|
|
36
|
+
token?: string;
|
|
37
|
+
}
|
|
38
|
+
interface PublishSlackHomeViewOptions {
|
|
39
|
+
client: SlackViewsClient;
|
|
40
|
+
userId: string;
|
|
41
|
+
view: HomeView;
|
|
42
|
+
hash?: string;
|
|
43
|
+
token?: string;
|
|
44
|
+
}
|
|
45
|
+
interface SlackViewPayload {
|
|
46
|
+
id?: string;
|
|
47
|
+
callback_id?: string;
|
|
48
|
+
private_metadata?: string;
|
|
49
|
+
state?: unknown;
|
|
50
|
+
hash?: string;
|
|
51
|
+
[key: string]: unknown;
|
|
52
|
+
}
|
|
53
|
+
interface SlackViewActor {
|
|
54
|
+
userId?: string;
|
|
55
|
+
teamId?: string;
|
|
56
|
+
enterpriseId?: string;
|
|
57
|
+
}
|
|
58
|
+
interface SlackViewSubmissionAckResponse {
|
|
59
|
+
response_action: "clear" | "errors" | "push" | "update";
|
|
60
|
+
errors?: Record<string, string>;
|
|
61
|
+
view?: View;
|
|
62
|
+
}
|
|
63
|
+
interface SlackViewWorkflowContext<TMetadata = unknown> {
|
|
64
|
+
body: unknown;
|
|
65
|
+
client: SlackViewsClient;
|
|
66
|
+
view: SlackViewPayload;
|
|
67
|
+
callbackId?: string;
|
|
68
|
+
triggerId?: string;
|
|
69
|
+
actor: SlackViewActor;
|
|
70
|
+
metadata: TMetadata | undefined;
|
|
71
|
+
}
|
|
72
|
+
interface RegisterSlackViewWorkflowOptions<TMetadata = unknown> {
|
|
73
|
+
boltApp: App;
|
|
74
|
+
callbackId: SlackViewCallbackId;
|
|
75
|
+
decodePrivateMetadata?: (privateMetadata: string | undefined, context: Omit<SlackViewWorkflowContext<TMetadata>, "metadata">) => TMetadata | undefined;
|
|
76
|
+
onSubmission?: (context: SlackViewWorkflowContext<TMetadata>) => SlackViewSubmissionAckResponse | void | Promise<SlackViewSubmissionAckResponse | void>;
|
|
77
|
+
onClose?: (context: SlackViewWorkflowContext<TMetadata>) => void | Promise<void>;
|
|
78
|
+
onError?: (error: unknown, context: Omit<SlackViewWorkflowContext<TMetadata>, "metadata"> & {
|
|
79
|
+
metadata?: TMetadata | undefined;
|
|
80
|
+
}) => void | Promise<void>;
|
|
81
|
+
}
|
|
82
|
+
interface SlackViewWorkflowRegistration {
|
|
83
|
+
callbackId: SlackViewCallbackId;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
declare function openSlackModal({ client, triggerId, view, token, }: OpenSlackModalOptions): Promise<SlackViewApiResponse>;
|
|
87
|
+
declare function pushSlackModal({ client, triggerId, view, token, }: PushSlackModalOptions): Promise<SlackViewApiResponse>;
|
|
88
|
+
declare function updateSlackView({ client, view, viewId, externalId, hash, token, }: UpdateSlackViewOptions): Promise<SlackViewApiResponse>;
|
|
89
|
+
declare function publishSlackHomeView({ client, userId, view, hash, token, }: PublishSlackHomeViewOptions): Promise<SlackViewApiResponse>;
|
|
90
|
+
|
|
91
|
+
declare const SLACK_VIEW_PRIVATE_METADATA_MAX_CHARS = 3000;
|
|
92
|
+
declare function encodeSlackViewPrivateMetadata(value: unknown): string;
|
|
93
|
+
declare function decodeSlackViewPrivateMetadata<T = unknown>(privateMetadata: string | undefined): T | undefined;
|
|
94
|
+
declare function readSlackViewPrivateMetadata<T = unknown>(view: Pick<SlackViewPayload, "private_metadata">): T | undefined;
|
|
95
|
+
|
|
96
|
+
declare function registerSlackViewWorkflow<TMetadata = unknown>({ boltApp, callbackId, decodePrivateMetadata, onSubmission, onClose, onError, }: RegisterSlackViewWorkflowOptions<TMetadata>): SlackViewWorkflowRegistration;
|
|
97
|
+
|
|
98
|
+
export { type OpenSlackModalOptions, type PublishSlackHomeViewOptions, type PushSlackModalOptions, type RegisterSlackViewWorkflowOptions, SLACK_VIEW_PRIVATE_METADATA_MAX_CHARS, type SlackViewActor, type SlackViewApiResponse, type SlackViewCallbackId, type SlackViewPayload, type SlackViewSubmissionAckResponse, type SlackViewWorkflowContext, type SlackViewWorkflowRegistration, type SlackViewsClient, type UpdateSlackViewOptions, decodeSlackViewPrivateMetadata, encodeSlackViewPrivateMetadata, openSlackModal, publishSlackHomeView, pushSlackModal, readSlackViewPrivateMetadata, registerSlackViewWorkflow, updateSlackView };
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import {
|
|
2
|
+
SLACK_VIEW_PRIVATE_METADATA_MAX_CHARS,
|
|
3
|
+
decodeSlackViewPrivateMetadata,
|
|
4
|
+
encodeSlackViewPrivateMetadata,
|
|
5
|
+
openSlackModal,
|
|
6
|
+
publishSlackHomeView,
|
|
7
|
+
pushSlackModal,
|
|
8
|
+
readSlackViewPrivateMetadata,
|
|
9
|
+
registerSlackViewWorkflow,
|
|
10
|
+
updateSlackView
|
|
11
|
+
} from "../chunk-IRFKUPJN.js";
|
|
12
|
+
export {
|
|
13
|
+
SLACK_VIEW_PRIVATE_METADATA_MAX_CHARS,
|
|
14
|
+
decodeSlackViewPrivateMetadata,
|
|
15
|
+
encodeSlackViewPrivateMetadata,
|
|
16
|
+
openSlackModal,
|
|
17
|
+
publishSlackHomeView,
|
|
18
|
+
pushSlackModal,
|
|
19
|
+
readSlackViewPrivateMetadata,
|
|
20
|
+
registerSlackViewWorkflow,
|
|
21
|
+
updateSlackView
|
|
22
|
+
};
|
package/docs/README.md
CHANGED
|
@@ -19,6 +19,7 @@ your adapter or application needs.
|
|
|
19
19
|
- [Setup requirements](concepts/setup-requirements.md)
|
|
20
20
|
- [Supplemental history](concepts/supplemental-history.md)
|
|
21
21
|
- [Transport runtime](concepts/transport-runtime.md)
|
|
22
|
+
- [Views](concepts/views.md)
|
|
22
23
|
|
|
23
24
|
## Recipes
|
|
24
25
|
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
# Slack Views
|
|
2
|
+
|
|
3
|
+
`@cuylabs/channel-slack/views` provides Slack-runtime primitives for modal and
|
|
4
|
+
Home view workflows. It keeps Slack Web API and Bolt details in
|
|
5
|
+
`channel-slack` while product packages decide what a workflow means.
|
|
6
|
+
|
|
7
|
+
```typescript
|
|
8
|
+
import {
|
|
9
|
+
encodeSlackViewPrivateMetadata,
|
|
10
|
+
openSlackModal,
|
|
11
|
+
registerSlackViewWorkflow,
|
|
12
|
+
} from "@cuylabs/channel-slack/views";
|
|
13
|
+
|
|
14
|
+
await openSlackModal({
|
|
15
|
+
client,
|
|
16
|
+
triggerId,
|
|
17
|
+
view: {
|
|
18
|
+
type: "modal",
|
|
19
|
+
callback_id: "incident_triage",
|
|
20
|
+
private_metadata: encodeSlackViewPrivateMetadata({
|
|
21
|
+
workflowId: "triage-123",
|
|
22
|
+
}),
|
|
23
|
+
title: { type: "plain_text", text: "Triage incident" },
|
|
24
|
+
submit: { type: "plain_text", text: "Continue" },
|
|
25
|
+
close: { type: "plain_text", text: "Cancel" },
|
|
26
|
+
blocks: [],
|
|
27
|
+
},
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
registerSlackViewWorkflow({
|
|
31
|
+
boltApp,
|
|
32
|
+
callbackId: "incident_triage",
|
|
33
|
+
onSubmission: async ({ metadata, view, actor }) => {
|
|
34
|
+
// Load product-owned workflow state by metadata.workflowId, validate
|
|
35
|
+
// view.state, then continue the workflow or return field errors.
|
|
36
|
+
return { response_action: "clear" };
|
|
37
|
+
},
|
|
38
|
+
});
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
Use `private_metadata` for compact routing data such as a workflow id, request
|
|
42
|
+
id, or session id. Store durable workflow state outside the view, for example in
|
|
43
|
+
the application database or the existing interactive-request store.
|
|
44
|
+
|
|
45
|
+
The `views` setup feature does not require a special bot scope, but it does
|
|
46
|
+
require Slack interactivity to be enabled for the app.
|
|
@@ -3,23 +3,24 @@
|
|
|
3
3
|
Use feature subpaths for new code. They make dependency expectations clearer and
|
|
4
4
|
keep application code close to the package boundary it uses.
|
|
5
5
|
|
|
6
|
-
| Export
|
|
7
|
-
|
|
|
8
|
-
| `@cuylabs/channel-slack/core`
|
|
9
|
-
| `@cuylabs/channel-slack/policy`
|
|
10
|
-
| `@cuylabs/channel-slack/history`
|
|
11
|
-
| `@cuylabs/channel-slack/app-home`
|
|
12
|
-
| `@cuylabs/channel-slack/artifacts`
|
|
13
|
-
| `@cuylabs/channel-slack/auth`
|
|
14
|
-
| `@cuylabs/channel-slack/transports`
|
|
15
|
-
| `@cuylabs/channel-slack/transports/http`
|
|
16
|
-
| `@cuylabs/channel-slack/transports/socket` | `@slack/bolt`; `pg` only when using connection-string Postgres locks
|
|
17
|
-
| `@cuylabs/channel-slack/setup`
|
|
18
|
-
| `@cuylabs/channel-slack/diagnostics`
|
|
19
|
-
| `@cuylabs/channel-slack/entrypoints`
|
|
20
|
-
| `@cuylabs/channel-slack/users`
|
|
21
|
-
| `@cuylabs/channel-slack/targets`
|
|
22
|
-
| `@cuylabs/channel-slack/feedback`
|
|
6
|
+
| Export | Depends on | Notes |
|
|
7
|
+
| ------------------------------------------ | ------------------------------------------------------------------------------- | ------------------------------------------------------------------------ |
|
|
8
|
+
| `@cuylabs/channel-slack/core` | no Slack SDK runtime imports | Transport-neutral parsing, formatting, types, sessions, turn context |
|
|
9
|
+
| `@cuylabs/channel-slack/policy` | `pg` only when using connection-string Postgres state | Message admission and in-memory/Postgres policy state |
|
|
10
|
+
| `@cuylabs/channel-slack/history` | `@slack/web-api` types | History reader accepts a Slack WebClient or minimal conversations client |
|
|
11
|
+
| `@cuylabs/channel-slack/app-home` | `@slack/bolt`, `@slack/types` | Slack App Home registration helper |
|
|
12
|
+
| `@cuylabs/channel-slack/artifacts` | no Slack SDK runtime imports; requires a Web API-like client at call time | Text, file, image, link, and Canvas artifact publishing |
|
|
13
|
+
| `@cuylabs/channel-slack/auth` | no Slack SDK runtime imports; `pg` is not required | Auth option types, auth resolution, OAuth installation stores |
|
|
14
|
+
| `@cuylabs/channel-slack/transports` | `@slack/bolt`, `express`; `pg` only when using connection-string Postgres locks | HTTP and Socket Mode transport helpers |
|
|
15
|
+
| `@cuylabs/channel-slack/transports/http` | `@slack/bolt`, `express` | HTTP Events API Bolt app factory |
|
|
16
|
+
| `@cuylabs/channel-slack/transports/socket` | `@slack/bolt`; `pg` only when using connection-string Postgres locks | Socket Mode app factory, runtime guard, process/Postgres locks |
|
|
17
|
+
| `@cuylabs/channel-slack/setup` | diagnostics only when inspecting live tokens | Setup requirements and app manifest helpers |
|
|
18
|
+
| `@cuylabs/channel-slack/diagnostics` | `@slack/web-api` | Token, auth, and scope inspection |
|
|
19
|
+
| `@cuylabs/channel-slack/entrypoints` | no Slack SDK runtime imports | Slash command and shortcut payload normalization |
|
|
20
|
+
| `@cuylabs/channel-slack/users` | `@slack/web-api` when using default client | User profile lookup and mention enrichment |
|
|
21
|
+
| `@cuylabs/channel-slack/targets` | no Slack SDK runtime imports unless resolving names through a client | Parse and resolve channel/user targets |
|
|
22
|
+
| `@cuylabs/channel-slack/feedback` | `@slack/types` types | Feedback block and action helpers |
|
|
23
|
+
| `@cuylabs/channel-slack/views` | `@slack/bolt`, `@slack/types` | Modal/Home view operations and workflow registration |
|
|
23
24
|
|
|
24
25
|
The root export remains available for lightweight core and policy helpers:
|
|
25
26
|
|
|
@@ -29,6 +29,7 @@ src/
|
|
|
29
29
|
socket/ Socket Mode Bolt app factory, runtime, locks
|
|
30
30
|
targets/ channel/user target parsing and resolution
|
|
31
31
|
users/ profile lookup and mention enrichment
|
|
32
|
+
views/ modal/Home view operations and workflow registration
|
|
32
33
|
```
|
|
33
34
|
|
|
34
35
|
For public export details and peer dependency expectations, see
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cuylabs/channel-slack",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.8.0",
|
|
4
4
|
"description": "Agent-runtime-agnostic Slack channel primitives for AI agents",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -71,6 +71,11 @@
|
|
|
71
71
|
"import": "./dist/targets/index.js",
|
|
72
72
|
"default": "./dist/targets/index.js"
|
|
73
73
|
},
|
|
74
|
+
"./turn-controls": {
|
|
75
|
+
"types": "./dist/turn-controls/index.d.ts",
|
|
76
|
+
"import": "./dist/turn-controls/index.js",
|
|
77
|
+
"default": "./dist/turn-controls/index.js"
|
|
78
|
+
},
|
|
74
79
|
"./transports": {
|
|
75
80
|
"types": "./dist/transports/index.d.ts",
|
|
76
81
|
"import": "./dist/transports/index.js",
|
|
@@ -90,6 +95,11 @@
|
|
|
90
95
|
"types": "./dist/users/index.d.ts",
|
|
91
96
|
"import": "./dist/users/index.js",
|
|
92
97
|
"default": "./dist/users/index.js"
|
|
98
|
+
},
|
|
99
|
+
"./views": {
|
|
100
|
+
"types": "./dist/views/index.d.ts",
|
|
101
|
+
"import": "./dist/views/index.js",
|
|
102
|
+
"default": "./dist/views/index.js"
|
|
93
103
|
}
|
|
94
104
|
},
|
|
95
105
|
"files": [
|
|
@@ -143,9 +153,9 @@
|
|
|
143
153
|
"node": ">=20"
|
|
144
154
|
},
|
|
145
155
|
"scripts": {
|
|
146
|
-
"build": "tsup src/index.ts src/app-home.ts src/artifacts/index.ts src/core.ts src/assistant/index.ts src/auth/index.ts src/diagnostics/index.ts src/entrypoints/index.ts src/feedback/index.ts src/history/index.ts src/policy/index.ts src/setup/index.ts src/targets/index.ts src/transports/index.ts src/transports/http/index.ts src/transports/socket/index.ts src/users/index.ts --format esm --dts --clean",
|
|
156
|
+
"build": "tsup src/index.ts src/app-home.ts src/artifacts/index.ts src/core.ts src/assistant/index.ts src/auth/index.ts src/diagnostics/index.ts src/entrypoints/index.ts src/feedback/index.ts src/history/index.ts src/policy/index.ts src/setup/index.ts src/targets/index.ts src/turn-controls/index.ts src/transports/index.ts src/transports/http/index.ts src/transports/socket/index.ts src/users/index.ts src/views/index.ts --format esm --dts --clean",
|
|
147
157
|
"clean": "rm -rf dist",
|
|
148
|
-
"dev": "tsup src/index.ts src/app-home.ts src/artifacts/index.ts src/core.ts src/assistant/index.ts src/auth/index.ts src/diagnostics/index.ts src/entrypoints/index.ts src/feedback/index.ts src/history/index.ts src/policy/index.ts src/setup/index.ts src/targets/index.ts src/transports/index.ts src/transports/http/index.ts src/transports/socket/index.ts src/users/index.ts --format esm --dts --watch",
|
|
158
|
+
"dev": "tsup src/index.ts src/app-home.ts src/artifacts/index.ts src/core.ts src/assistant/index.ts src/auth/index.ts src/diagnostics/index.ts src/entrypoints/index.ts src/feedback/index.ts src/history/index.ts src/policy/index.ts src/setup/index.ts src/targets/index.ts src/turn-controls/index.ts src/transports/index.ts src/transports/http/index.ts src/transports/socket/index.ts src/users/index.ts src/views/index.ts --format esm --dts --watch",
|
|
149
159
|
"lint": "eslint \"src/**/*.{ts,tsx}\" \"tests/**/*.{ts,tsx}\" --max-warnings=0",
|
|
150
160
|
"test": "vitest run",
|
|
151
161
|
"test:watch": "vitest",
|
|
File without changes
|