@cuylabs/channel-slack 0.10.0 → 0.12.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 +36 -3
- package/dist/adapter/index.d.ts +53 -0
- package/dist/adapter/index.js +13 -0
- package/dist/app-surface.d.ts +86 -0
- package/dist/app-surface.js +15 -0
- package/dist/app.d.ts +58 -0
- package/dist/app.js +86 -0
- package/dist/artifacts/index.d.ts +57 -3
- package/dist/artifacts/index.js +88 -0
- package/dist/assistant/index.d.ts +18 -53
- package/dist/assistant/index.js +15 -184
- package/dist/bolt-app-BM0tiL7c.d.ts +49 -0
- package/dist/{chunk-TWJGVDA2.js → chunk-37RN2YUI.js} +88 -1
- package/dist/chunk-LFQCINHI.js +187 -0
- package/dist/chunk-Q6YX7HHK.js +1062 -0
- package/dist/chunk-RHOIVQLD.js +127 -0
- package/dist/chunk-RTDLIYEE.js +446 -0
- package/dist/core.d.ts +5 -201
- package/dist/core.js +10 -12
- package/dist/feedback/index.d.ts +2 -2
- package/dist/feedback/index.js +5 -120
- package/dist/formatting-C-kwQseI.d.ts +25 -0
- package/dist/index.d.ts +6 -3
- package/dist/index.js +10 -12
- package/dist/interactive/index.d.ts +68 -4
- package/dist/interactive/index.js +432 -0
- package/dist/options-B0xQCaez.d.ts +221 -0
- package/dist/options-DQacQDmD.d.ts +368 -0
- package/dist/runtime/index.d.ts +6 -220
- package/dist/socket.d.ts +142 -0
- package/dist/socket.js +77 -0
- package/dist/transports/index.d.ts +2 -1
- package/dist/transports/socket/index.d.ts +4 -49
- package/dist/turn-BGAXddH_.d.ts +178 -0
- package/dist/types-wLZzyI9r.d.ts +375 -0
- package/docs/README.md +1 -0
- package/docs/concepts/interactive-requests.md +85 -0
- package/docs/reference/channel-slack-boundary.md +6 -3
- package/docs/reference/exports.md +6 -2
- package/docs/reference/source-layout.md +1 -0
- package/package.json +23 -3
- package/dist/chunk-ISOMBQXE.js +0 -89
|
@@ -0,0 +1,368 @@
|
|
|
1
|
+
import { AssistantUserMessageMiddleware, AssistantThreadStartedMiddleware, Assistant, App } from '@slack/bolt';
|
|
2
|
+
import { WebClient } from '@slack/web-api';
|
|
3
|
+
import { f as SlackAuthContext, d as SlackAssistantThreadContext, e as SlackAssistantUtilities, j as SlackTurnPreparation, c as SlackAssistantTaskDisplayMode, S as SlackAssistantStatusUpdate, b as SlackAssistantSuggestedPrompts, g as SlackChatStreamStartArgs } from './turn-BGAXddH_.js';
|
|
4
|
+
import { h as SlackInteractiveRequestHandler } from './interactive-CbKYkkc_.js';
|
|
5
|
+
import { a as SlackMessageFormattingOptions } from './formatting-C-kwQseI.js';
|
|
6
|
+
import { o as SlackTurnSource, i as SlackTurnEvent, S as SlackEventBridgeOptions } from './options-B0xQCaez.js';
|
|
7
|
+
import { SlackFeedbackBlockOptions, SlackFeedbackHandler } from './feedback/index.js';
|
|
8
|
+
import { S as SlackActivityInfo } from './activity-ByrD9Ftr.js';
|
|
9
|
+
import { L as Logger } from './logging-Bl3HfcC8.js';
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Per-thread Assistant context store.
|
|
13
|
+
*
|
|
14
|
+
* Bolt's default store persists context in message metadata, but also keeps a
|
|
15
|
+
* single process-local cached context. That cache is not keyed by thread, so a
|
|
16
|
+
* multi-user app can read the wrong channel-of-origin context after another
|
|
17
|
+
* assistant thread changes it. This store keeps the same metadata persistence
|
|
18
|
+
* model while caching by Slack channel/thread.
|
|
19
|
+
*/
|
|
20
|
+
type ThreadStoreArgs = {
|
|
21
|
+
context?: {
|
|
22
|
+
botUserId?: string;
|
|
23
|
+
};
|
|
24
|
+
client?: {
|
|
25
|
+
conversations?: {
|
|
26
|
+
replies?: (args: Record<string, unknown>) => Promise<{
|
|
27
|
+
messages?: unknown[];
|
|
28
|
+
}>;
|
|
29
|
+
};
|
|
30
|
+
chat?: {
|
|
31
|
+
update?: (args: Record<string, unknown>) => Promise<unknown>;
|
|
32
|
+
};
|
|
33
|
+
};
|
|
34
|
+
logger?: {
|
|
35
|
+
debug?: (...args: unknown[]) => void;
|
|
36
|
+
};
|
|
37
|
+
payload?: unknown;
|
|
38
|
+
};
|
|
39
|
+
interface SlackAssistantThreadContextStoreLike {
|
|
40
|
+
get: (args: ThreadStoreArgs) => Promise<unknown>;
|
|
41
|
+
save: (args: ThreadStoreArgs) => Promise<void>;
|
|
42
|
+
}
|
|
43
|
+
declare function createSlackAssistantThreadContextStore(): SlackAssistantThreadContextStoreLike;
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* Parse the `message` payload delivered to a Bolt assistant `userMessage`
|
|
47
|
+
* handler into the same shape as `parseSlackMessageActivity`.
|
|
48
|
+
*
|
|
49
|
+
* Bolt routes a fairly wide message event to assistant handlers, so we keep
|
|
50
|
+
* the input typed loosely and inspect only the fields we need.
|
|
51
|
+
*/
|
|
52
|
+
|
|
53
|
+
interface ParsedAssistantUserMessage extends SlackActivityInfo {
|
|
54
|
+
/** Slack `channel` identifier, always present after parsing. */
|
|
55
|
+
channel: string;
|
|
56
|
+
/** Slack `thread_ts` identifier — the assistant API requires a thread. */
|
|
57
|
+
threadTs: string;
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* Returns `undefined` when the event is not a parseable user message — bolt
|
|
61
|
+
* delivers join/leave/edit/delete subtypes through the same handler, and the
|
|
62
|
+
* caller should ignore them.
|
|
63
|
+
*/
|
|
64
|
+
declare function parseSlackMessageActivityFromMessageEvent(message: unknown): ParsedAssistantUserMessage | undefined;
|
|
65
|
+
|
|
66
|
+
type SlackAssistantCancelControlVisibleWhen = "before-output" | "always-while-active";
|
|
67
|
+
interface SlackAssistantCancelControlOptions {
|
|
68
|
+
actionId?: string;
|
|
69
|
+
buttonText?: string;
|
|
70
|
+
messageText?: string;
|
|
71
|
+
visibleWhen?: SlackAssistantCancelControlVisibleWhen;
|
|
72
|
+
canceledAck?: string | false;
|
|
73
|
+
alreadyCompletedAck?: string | false;
|
|
74
|
+
unauthorizedAck?: string | false;
|
|
75
|
+
onCancel?: (context: SlackAssistantTurnCancelContext) => MaybePromise<void>;
|
|
76
|
+
}
|
|
77
|
+
interface SlackAssistantTurnControlsOptions {
|
|
78
|
+
cancel?: true | SlackAssistantCancelControlOptions;
|
|
79
|
+
}
|
|
80
|
+
interface SlackAssistantTurnCancelContext {
|
|
81
|
+
controlId: string;
|
|
82
|
+
sessionId: string;
|
|
83
|
+
channelId: string;
|
|
84
|
+
threadTs: string;
|
|
85
|
+
userId: string;
|
|
86
|
+
teamId?: string;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
/**
|
|
90
|
+
* Session strategies for the Bolt Assistant bridge.
|
|
91
|
+
*
|
|
92
|
+
* Slack assistant conversations are always threaded, including Assistant DMs,
|
|
93
|
+
* so the default assistant mapping keys sessions by `channel:thread_ts`. This
|
|
94
|
+
* intentionally differs from the shared channel adapter, where plain DMs use
|
|
95
|
+
* only the DM channel id.
|
|
96
|
+
*/
|
|
97
|
+
|
|
98
|
+
type SlackAssistantSessionStrategy = "thread-aware" | "channel-id" | "user-per-thread";
|
|
99
|
+
declare function resolveAssistantSessionId(message: ParsedAssistantUserMessage, strategy: SlackAssistantSessionStrategy): string;
|
|
100
|
+
|
|
101
|
+
/**
|
|
102
|
+
* Public option types for the Slack Assistant bridge.
|
|
103
|
+
*
|
|
104
|
+
* Kept in a dedicated file so the lifecycle handlers, sink, and helpers can
|
|
105
|
+
* reference them without dragging the entire factory in.
|
|
106
|
+
*/
|
|
107
|
+
|
|
108
|
+
type MaybePromise<T> = T | Promise<T>;
|
|
109
|
+
/**
|
|
110
|
+
* Loose alias for the runtime shape of arguments handed to assistant
|
|
111
|
+
* lifecycle middleware. Bolt does not re-export `AllAssistantMiddlewareArgs`
|
|
112
|
+
* either, but every handler we register receives a compatible record.
|
|
113
|
+
*/
|
|
114
|
+
type AssistantLifecycleArgs = Parameters<AssistantUserMessageMiddleware>[0];
|
|
115
|
+
/** Args specifically for the `threadStarted` middleware. */
|
|
116
|
+
type AssistantThreadStartedArgs = Parameters<AssistantThreadStartedMiddleware>[0];
|
|
117
|
+
/**
|
|
118
|
+
* Context handed to `getSuggestedPrompts` / `getInitialReply` /
|
|
119
|
+
* `formatThreadTitle` when a Slack assistant thread starts.
|
|
120
|
+
*/
|
|
121
|
+
interface SlackAssistantThreadStartedContext {
|
|
122
|
+
/** The raw `assistant_thread_started` event payload. */
|
|
123
|
+
event: AssistantThreadStartedArgs["payload"];
|
|
124
|
+
context: AssistantThreadStartedArgs["context"];
|
|
125
|
+
client: AssistantThreadStartedArgs["client"];
|
|
126
|
+
logger: AssistantThreadStartedArgs["logger"];
|
|
127
|
+
}
|
|
128
|
+
/**
|
|
129
|
+
* Context for per-message agent-side preparation. Returned values augment the
|
|
130
|
+
* Slack turn but never replace the bridge's lifecycle calls (status, stream,
|
|
131
|
+
* feedback, etc.).
|
|
132
|
+
*
|
|
133
|
+
* `auth`, `threadContext`, and `assistant` are populated by the bridge before
|
|
134
|
+
* `prepareTurn` / `resolveSession` run, so callers can read tokens and the
|
|
135
|
+
* channel-of-origin metadata (or call `setStatus` etc. mid-prep) without
|
|
136
|
+
* reaching into `rawArgs`.
|
|
137
|
+
*/
|
|
138
|
+
interface SlackAssistantUserMessageContext {
|
|
139
|
+
message: ParsedAssistantUserMessage;
|
|
140
|
+
sessionId: string;
|
|
141
|
+
/** Slack Web API client for direct Slack calls scoped to this turn. */
|
|
142
|
+
client: WebClient;
|
|
143
|
+
rawArgs: AssistantLifecycleArgs;
|
|
144
|
+
/** Slack auth + identity for the inbound request. */
|
|
145
|
+
auth: SlackAuthContext;
|
|
146
|
+
/**
|
|
147
|
+
* Bolt-resolved assistant thread context (channel of origin, etc.).
|
|
148
|
+
*
|
|
149
|
+
* Populated lazily on first read via `getThreadContext()`. The bridge
|
|
150
|
+
* resolves it once per turn and caches it so handlers don't have to.
|
|
151
|
+
*/
|
|
152
|
+
threadContext: SlackAssistantThreadContext;
|
|
153
|
+
/**
|
|
154
|
+
* Assistant pane utilities (`setStatus`, `setSuggestedPrompts`, `setTitle`,
|
|
155
|
+
* `getThreadContext`, `saveThreadContext`).
|
|
156
|
+
*/
|
|
157
|
+
assistant: SlackAssistantUtilities;
|
|
158
|
+
}
|
|
159
|
+
interface SlackAssistantTurnPreparation extends SlackTurnPreparation {
|
|
160
|
+
}
|
|
161
|
+
interface SlackAssistantStatusContext {
|
|
162
|
+
event: SlackTurnEvent;
|
|
163
|
+
rawArgs: AssistantLifecycleArgs;
|
|
164
|
+
}
|
|
165
|
+
/**
|
|
166
|
+
* Configuration for the feedback block attached to assistant replies.
|
|
167
|
+
*/
|
|
168
|
+
interface SlackAssistantFeedbackConfig extends SlackFeedbackBlockOptions {
|
|
169
|
+
/**
|
|
170
|
+
* Called after the user clicks a feedback button. The bridge already calls
|
|
171
|
+
* `ack()` and posts an ephemeral acknowledgement (configurable below).
|
|
172
|
+
*/
|
|
173
|
+
onFeedback?: SlackFeedbackHandler;
|
|
174
|
+
/** Ephemeral text shown after a positive click. Set to `false` to skip. */
|
|
175
|
+
positiveAck?: string | false;
|
|
176
|
+
/** Ephemeral text shown after a negative click. */
|
|
177
|
+
negativeAck?: string | false;
|
|
178
|
+
}
|
|
179
|
+
interface CreateSlackAssistantBridgeOptions {
|
|
180
|
+
/**
|
|
181
|
+
* Source of Slack turns. Any object satisfying `SlackTurnSource` works.
|
|
182
|
+
*/
|
|
183
|
+
source: SlackTurnSource;
|
|
184
|
+
/**
|
|
185
|
+
* Custom Bolt thread context store. Defaults to Bolt's
|
|
186
|
+
* `DefaultThreadContextStore` (metadata-on-message persistence).
|
|
187
|
+
*/
|
|
188
|
+
threadContextStore?: SlackAssistantThreadContextStoreLike;
|
|
189
|
+
/**
|
|
190
|
+
* Session strategy for messages routed through the assistant.
|
|
191
|
+
* The default `"thread-aware"` strategy maps Slack Assistant threads to
|
|
192
|
+
* `${channelId}:${threadTs}`, including Assistant DM threads.
|
|
193
|
+
*
|
|
194
|
+
* @default "thread-aware"
|
|
195
|
+
*/
|
|
196
|
+
sessionStrategy?: SlackAssistantSessionStrategy;
|
|
197
|
+
/**
|
|
198
|
+
* Optional explicit session resolver. Returning a falsy value falls back to
|
|
199
|
+
* the configured strategy.
|
|
200
|
+
*/
|
|
201
|
+
resolveSession?: (request: SlackAssistantUserMessageContext) => MaybePromise<string | undefined>;
|
|
202
|
+
/**
|
|
203
|
+
* Optional per-turn preparation hook.
|
|
204
|
+
*/
|
|
205
|
+
prepareTurn?: (request: SlackAssistantUserMessageContext) => MaybePromise<SlackAssistantTurnPreparation | undefined>;
|
|
206
|
+
/**
|
|
207
|
+
* Display mode for `client.chatStream`.
|
|
208
|
+
*
|
|
209
|
+
* - `"timeline"` (default) — linear streaming, best for chat answers.
|
|
210
|
+
* - `"plan"` — task list with `task_update` chunks. Pair with the agent
|
|
211
|
+
* emitting tool-start/tool-result events for the task UI.
|
|
212
|
+
*/
|
|
213
|
+
taskDisplayMode?: SlackAssistantTaskDisplayMode;
|
|
214
|
+
/**
|
|
215
|
+
* Initial assistant pane status set immediately when a user message arrives.
|
|
216
|
+
*
|
|
217
|
+
* @default { status: "Thinking..." }
|
|
218
|
+
*/
|
|
219
|
+
initialStatus?: SlackAssistantStatusUpdate | ((request: SlackAssistantUserMessageContext) => MaybePromise<SlackAssistantStatusUpdate | undefined>);
|
|
220
|
+
/**
|
|
221
|
+
* Map an SlackTurnEvent to an assistant pane status update. Returning
|
|
222
|
+
* `undefined` keeps the previous status.
|
|
223
|
+
*/
|
|
224
|
+
formatStatus?: (context: SlackAssistantStatusContext) => MaybePromise<SlackAssistantStatusUpdate | undefined>;
|
|
225
|
+
/**
|
|
226
|
+
* Suggested prompts shown when an assistant thread is opened.
|
|
227
|
+
*/
|
|
228
|
+
getSuggestedPrompts?: (context: SlackAssistantThreadStartedContext) => MaybePromise<SlackAssistantSuggestedPrompts | undefined>;
|
|
229
|
+
/**
|
|
230
|
+
* Optional follow-up prompts surfaced after a successful turn completes.
|
|
231
|
+
*
|
|
232
|
+
* When provided and a non-empty result is returned, the bridge calls
|
|
233
|
+
* `assistant.threads.setSuggestedPrompts(...)` after the streaming reply
|
|
234
|
+
* has been finalized. Errors from this hook are logged and never break
|
|
235
|
+
* the turn.
|
|
236
|
+
*/
|
|
237
|
+
getFollowUpPrompts?: (context: SlackAssistantUserMessageContext & {
|
|
238
|
+
finalText: string;
|
|
239
|
+
}) => MaybePromise<SlackAssistantSuggestedPrompts | undefined>;
|
|
240
|
+
/**
|
|
241
|
+
* Greeting message posted when an assistant thread is opened.
|
|
242
|
+
*
|
|
243
|
+
* @default "Hi, how can I help?"
|
|
244
|
+
*/
|
|
245
|
+
getInitialReply?: (context: SlackAssistantThreadStartedContext) => MaybePromise<string | false | undefined>;
|
|
246
|
+
/**
|
|
247
|
+
* Called once per assistant turn to set the thread title via
|
|
248
|
+
* `assistant.threads.setTitle`. Return `undefined` to skip.
|
|
249
|
+
*/
|
|
250
|
+
formatThreadTitle?: (request: SlackAssistantUserMessageContext) => MaybePromise<string | undefined>;
|
|
251
|
+
/**
|
|
252
|
+
* Feedback block configuration.
|
|
253
|
+
*
|
|
254
|
+
* - Object: builder + handler config (default).
|
|
255
|
+
* - `false`: omit the feedback block entirely.
|
|
256
|
+
*/
|
|
257
|
+
feedback?: SlackAssistantFeedbackConfig | false;
|
|
258
|
+
/**
|
|
259
|
+
* Optional active-turn controls rendered in Slack while an assistant turn is
|
|
260
|
+
* running. The cancel control aborts the underlying `SlackTurnSource` via
|
|
261
|
+
* the per-turn `AbortSignal`, so any runtime implementing that contract can
|
|
262
|
+
* participate without Slack-specific code.
|
|
263
|
+
*/
|
|
264
|
+
turnControls?: SlackAssistantTurnControlsOptions;
|
|
265
|
+
/**
|
|
266
|
+
* Bridge options forwarded to `bridgeSlackTurnEventsToSlack`. Streaming mode is
|
|
267
|
+
* pinned to `"chat-stream"` and cannot be overridden here.
|
|
268
|
+
*/
|
|
269
|
+
showReasoning?: boolean;
|
|
270
|
+
/** Render root-agent tool rows/status updates. Defaults to true. */
|
|
271
|
+
showToolUsage?: boolean;
|
|
272
|
+
/** Render subagent child tool rows. Defaults to false. */
|
|
273
|
+
showSubagentToolUsage?: boolean;
|
|
274
|
+
/** Include full subagent final output in the task row. Defaults to false. */
|
|
275
|
+
showSubagentResultInTask?: boolean;
|
|
276
|
+
formatToolTitle?: (toolName: string) => string;
|
|
277
|
+
formatToolUpdate?: (toolName: string) => string;
|
|
278
|
+
formatToolDetails?: SlackEventBridgeOptions["formatToolDetails"];
|
|
279
|
+
formatToolResultOutput?: SlackEventBridgeOptions["formatToolResultOutput"];
|
|
280
|
+
formatToolError?: (toolName: string, error: string) => string;
|
|
281
|
+
formatReasoningUpdate?: () => string;
|
|
282
|
+
chatStreamBufferSize?: number;
|
|
283
|
+
maxTaskUpdates?: number;
|
|
284
|
+
maxTaskUpdateTextChars?: number;
|
|
285
|
+
maxTaskUpdateFieldChars?: number;
|
|
286
|
+
/**
|
|
287
|
+
* Start arguments merged into Slack's native chat stream.
|
|
288
|
+
*
|
|
289
|
+
* Use this for Slack-supported authorship fields such as `icon_emoji`,
|
|
290
|
+
* `icon_url`, and `username`. The bridge still owns channel, thread,
|
|
291
|
+
* recipient ids, task display mode, and buffer size.
|
|
292
|
+
*/
|
|
293
|
+
chatStreamStartArgs?: SlackChatStreamStartArgs;
|
|
294
|
+
/**
|
|
295
|
+
* Final arguments merged into `chatStream.stop(...)`.
|
|
296
|
+
*
|
|
297
|
+
* Use this for static footer blocks such as content disclaimers. When
|
|
298
|
+
* feedback is enabled, the feedback block is appended after any configured
|
|
299
|
+
* blocks.
|
|
300
|
+
*/
|
|
301
|
+
chatStreamFinalArgs?: SlackEventBridgeOptions["chatStreamFinalArgs"];
|
|
302
|
+
/**
|
|
303
|
+
* Optional publisher for rich artifacts derived from the final accumulated
|
|
304
|
+
* answer, such as creating a Slack Canvas for long responses.
|
|
305
|
+
*/
|
|
306
|
+
publishFinalResponseArtifact?: SlackEventBridgeOptions["publishFinalResponseArtifact"];
|
|
307
|
+
/**
|
|
308
|
+
* Controls whether final-response artifacts are supplemental or replace long
|
|
309
|
+
* Slack text with a compact artifact pointer.
|
|
310
|
+
*
|
|
311
|
+
* @default "supplemental"
|
|
312
|
+
*/
|
|
313
|
+
finalResponseArtifactMode?: SlackEventBridgeOptions["finalResponseArtifactMode"];
|
|
314
|
+
/**
|
|
315
|
+
* Raw-character threshold for replacement-mode streaming suppression.
|
|
316
|
+
*
|
|
317
|
+
* @default 4000
|
|
318
|
+
*/
|
|
319
|
+
finalResponseArtifactStreamThreshold?: SlackEventBridgeOptions["finalResponseArtifactStreamThreshold"];
|
|
320
|
+
/** Notice emitted when replacement mode moves the remaining response to an artifact. */
|
|
321
|
+
formatFinalResponseArtifactContinuationNotice?: SlackEventBridgeOptions["formatFinalResponseArtifactContinuationNotice"];
|
|
322
|
+
/** Compact final Slack message emitted after artifact publication succeeds. */
|
|
323
|
+
formatFinalResponseArtifactMessage?: SlackEventBridgeOptions["formatFinalResponseArtifactMessage"];
|
|
324
|
+
/** Diagnostics hook for final-response artifact publishing failures. */
|
|
325
|
+
onFinalResponseArtifactError?: SlackEventBridgeOptions["onFinalResponseArtifactError"];
|
|
326
|
+
formatChatMarkdown?: SlackMessageFormattingOptions;
|
|
327
|
+
formatStreamError?: (error: Error) => string;
|
|
328
|
+
/**
|
|
329
|
+
* Slack-native renderer/resolver hook for approval and human-input
|
|
330
|
+
* requests. Return `true` after rendering/recording the request to keep the
|
|
331
|
+
* Slack turn alive while an out-of-band Slack action resolves it.
|
|
332
|
+
*/
|
|
333
|
+
handleInteractiveRequest?: SlackInteractiveRequestHandler;
|
|
334
|
+
/**
|
|
335
|
+
* Maximum time to let an assistant turn run before aborting the underlying
|
|
336
|
+
* `SlackTurnSource`.
|
|
337
|
+
*
|
|
338
|
+
* Set to `0` to disable the timeout.
|
|
339
|
+
*
|
|
340
|
+
* @default 120000
|
|
341
|
+
*/
|
|
342
|
+
timeoutMs?: number;
|
|
343
|
+
/**
|
|
344
|
+
* Optional logger for bridge diagnostics.
|
|
345
|
+
*/
|
|
346
|
+
logger?: Logger;
|
|
347
|
+
}
|
|
348
|
+
interface SlackAssistantBridge {
|
|
349
|
+
/** The Bolt `Assistant` middleware instance to pass to `app.assistant(...)`. */
|
|
350
|
+
assistant: Assistant;
|
|
351
|
+
/**
|
|
352
|
+
* Wire the assistant + feedback action handler onto a Bolt `App` in one
|
|
353
|
+
* call. Equivalent to `app.assistant(bridge.assistant)` plus the feedback
|
|
354
|
+
* action registration when feedback is enabled.
|
|
355
|
+
*/
|
|
356
|
+
install(app: App): void;
|
|
357
|
+
/**
|
|
358
|
+
* The resolved feedback action id, or `undefined` when feedback is disabled.
|
|
359
|
+
*/
|
|
360
|
+
feedbackActionId?: string;
|
|
361
|
+
/**
|
|
362
|
+
* The resolved cancel action id, or `undefined` when turn cancel controls are
|
|
363
|
+
* disabled.
|
|
364
|
+
*/
|
|
365
|
+
turnCancelActionId?: string;
|
|
366
|
+
}
|
|
367
|
+
|
|
368
|
+
export { type AssistantLifecycleArgs as A, type CreateSlackAssistantBridgeOptions as C, type MaybePromise as M, type ParsedAssistantUserMessage as P, type SlackAssistantBridge as S, type AssistantThreadStartedArgs as a, type SlackAssistantCancelControlOptions as b, type SlackAssistantCancelControlVisibleWhen as c, type SlackAssistantFeedbackConfig as d, type SlackAssistantSessionStrategy as e, type SlackAssistantStatusContext as f, type SlackAssistantThreadContextStoreLike as g, type SlackAssistantThreadStartedContext as h, type SlackAssistantTurnCancelContext as i, type SlackAssistantTurnControlsOptions as j, type SlackAssistantTurnPreparation as k, type SlackAssistantUserMessageContext as l, createSlackAssistantThreadContextStore as m, parseSlackMessageActivityFromMessageEvent as p, resolveAssistantSessionId as r };
|
package/dist/runtime/index.d.ts
CHANGED
|
@@ -1,225 +1,11 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
import { a as SlackEventInteractiveRequestHandler } from '../interactive-CbKYkkc_.js';
|
|
1
|
+
import { i as SlackTurnEvent, S as SlackEventBridgeOptions } from '../options-B0xQCaez.js';
|
|
2
|
+
export { a as SlackFinalResponseArtifactContext, b as SlackFinalResponseArtifactDeliveryMode, c as SlackFinalResponseArtifactPublisher, d as SlackFinalResponseArtifactResult, e as SlackTurnApprovalRequestEvent, f as SlackTurnApprovalResolvedEvent, g as SlackTurnCompleteEvent, h as SlackTurnErrorEvent, j as SlackTurnEventBase, k as SlackTurnHumanInputRequestEvent, l as SlackTurnHumanInputResolvedEvent, m as SlackTurnReasoningEndEvent, n as SlackTurnReasoningStartEvent, o as SlackTurnSource, p as SlackTurnSourceChatOptions, q as SlackTurnStatus, r as SlackTurnStatusEvent, s as SlackTurnSubagentCompleteEvent, t as SlackTurnSubagentErrorEvent, u as SlackTurnSubagentEventBase, v as SlackTurnSubagentEventEvent, w as SlackTurnSubagentStartEvent, x as SlackTurnTextDeltaEvent, y as SlackTurnTextEndEvent, z as SlackTurnTextStartEvent, A as SlackTurnToolErrorEvent, B as SlackTurnToolResultEvent, C as SlackTurnToolStartEvent, D as resolveSlackEventBridgeOptions } from '../options-B0xQCaez.js';
|
|
4
3
|
import { SlackResponseSink } from '../responses/index.js';
|
|
4
|
+
import '../types-C8nkPuD4.js';
|
|
5
|
+
import '../types-Cywfj8Mj.js';
|
|
6
|
+
import '../interactive-CbKYkkc_.js';
|
|
5
7
|
import '../activity-ByrD9Ftr.js';
|
|
6
8
|
|
|
7
|
-
interface SlackTurnSourceChatOptions {
|
|
8
|
-
abort?: AbortSignal;
|
|
9
|
-
system?: string;
|
|
10
|
-
}
|
|
11
|
-
interface SlackTurnSource {
|
|
12
|
-
chat(sessionId: string, message: string, options?: SlackTurnSourceChatOptions): AsyncGenerator<SlackTurnEvent>;
|
|
13
|
-
}
|
|
14
|
-
interface SlackFinalResponseArtifactContext {
|
|
15
|
-
text: string;
|
|
16
|
-
formattedText: string;
|
|
17
|
-
client: SlackArtifactClient;
|
|
18
|
-
channelId: string;
|
|
19
|
-
threadTs?: string;
|
|
20
|
-
}
|
|
21
|
-
interface SlackFinalResponseArtifactResult {
|
|
22
|
-
publication: SlackArtifactPublication;
|
|
23
|
-
}
|
|
24
|
-
type SlackFinalResponseArtifactDeliveryMode = "supplemental" | "replace";
|
|
25
|
-
type SlackFinalResponseArtifactPublisher = (context: SlackFinalResponseArtifactContext) => Promise<SlackFinalResponseArtifactResult | undefined>;
|
|
26
|
-
type SlackTurnStatus = "thinking" | "reasoning" | "calling-tool" | "waiting-approval" | "waiting-input" | "processing" | "error" | string;
|
|
27
|
-
interface SlackTurnEventBase {
|
|
28
|
-
type: string;
|
|
29
|
-
[key: string]: unknown;
|
|
30
|
-
}
|
|
31
|
-
interface SlackTurnTextStartEvent extends SlackTurnEventBase {
|
|
32
|
-
type: "text-start";
|
|
33
|
-
}
|
|
34
|
-
interface SlackTurnTextDeltaEvent extends SlackTurnEventBase {
|
|
35
|
-
type: "text-delta";
|
|
36
|
-
text: string;
|
|
37
|
-
}
|
|
38
|
-
interface SlackTurnTextEndEvent extends SlackTurnEventBase {
|
|
39
|
-
type: "text-end";
|
|
40
|
-
}
|
|
41
|
-
interface SlackTurnReasoningStartEvent extends SlackTurnEventBase {
|
|
42
|
-
type: "reasoning-start";
|
|
43
|
-
}
|
|
44
|
-
interface SlackTurnReasoningEndEvent extends SlackTurnEventBase {
|
|
45
|
-
type: "reasoning-end";
|
|
46
|
-
}
|
|
47
|
-
interface SlackTurnToolStartEvent extends SlackTurnEventBase {
|
|
48
|
-
type: "tool-start";
|
|
49
|
-
toolCallId: string;
|
|
50
|
-
toolName: string;
|
|
51
|
-
input?: unknown;
|
|
52
|
-
}
|
|
53
|
-
interface SlackTurnToolResultEvent extends SlackTurnEventBase {
|
|
54
|
-
type: "tool-result";
|
|
55
|
-
toolCallId: string;
|
|
56
|
-
toolName: string;
|
|
57
|
-
result?: unknown;
|
|
58
|
-
}
|
|
59
|
-
interface SlackTurnToolErrorEvent extends SlackTurnEventBase {
|
|
60
|
-
type: "tool-error";
|
|
61
|
-
toolCallId: string;
|
|
62
|
-
toolName: string;
|
|
63
|
-
error: string;
|
|
64
|
-
}
|
|
65
|
-
interface SlackTurnSubagentEventBase extends SlackTurnEventBase {
|
|
66
|
-
dispatchId: string;
|
|
67
|
-
role: string;
|
|
68
|
-
title?: string;
|
|
69
|
-
parentDispatchId?: string;
|
|
70
|
-
agentPath?: string;
|
|
71
|
-
depth?: number;
|
|
72
|
-
}
|
|
73
|
-
interface SlackTurnSubagentStartEvent extends SlackTurnSubagentEventBase {
|
|
74
|
-
type: "subagent-start";
|
|
75
|
-
}
|
|
76
|
-
interface SlackTurnSubagentEventEvent extends SlackTurnSubagentEventBase {
|
|
77
|
-
type: "subagent-event";
|
|
78
|
-
event: SlackTurnEvent;
|
|
79
|
-
}
|
|
80
|
-
interface SlackTurnSubagentCompleteEvent extends SlackTurnSubagentEventBase {
|
|
81
|
-
type: "subagent-complete";
|
|
82
|
-
output?: unknown;
|
|
83
|
-
}
|
|
84
|
-
interface SlackTurnSubagentErrorEvent extends SlackTurnSubagentEventBase {
|
|
85
|
-
type: "subagent-error";
|
|
86
|
-
error: string;
|
|
87
|
-
}
|
|
88
|
-
interface SlackTurnStatusEvent extends SlackTurnEventBase {
|
|
89
|
-
type: "status";
|
|
90
|
-
status: SlackTurnStatus;
|
|
91
|
-
}
|
|
92
|
-
interface SlackTurnCompleteEvent extends SlackTurnEventBase {
|
|
93
|
-
type: "complete";
|
|
94
|
-
output?: string;
|
|
95
|
-
}
|
|
96
|
-
interface SlackTurnErrorEvent extends SlackTurnEventBase {
|
|
97
|
-
type: "error";
|
|
98
|
-
error: unknown;
|
|
99
|
-
}
|
|
100
|
-
interface SlackTurnApprovalRequestEvent extends SlackTurnEventBase {
|
|
101
|
-
type: "approval-request";
|
|
102
|
-
request: SlackInteractiveApprovalRequest;
|
|
103
|
-
}
|
|
104
|
-
interface SlackTurnApprovalResolvedEvent extends SlackTurnEventBase {
|
|
105
|
-
type: "approval-resolved";
|
|
106
|
-
}
|
|
107
|
-
interface SlackTurnHumanInputRequestEvent extends SlackTurnEventBase {
|
|
108
|
-
type: "human-input-request";
|
|
109
|
-
request: SlackInteractiveHumanInputRequest;
|
|
110
|
-
}
|
|
111
|
-
interface SlackTurnHumanInputResolvedEvent extends SlackTurnEventBase {
|
|
112
|
-
type: "human-input-resolved";
|
|
113
|
-
}
|
|
114
|
-
type SlackTurnEvent = SlackTurnTextStartEvent | SlackTurnTextDeltaEvent | SlackTurnTextEndEvent | SlackTurnReasoningStartEvent | SlackTurnReasoningEndEvent | SlackTurnToolStartEvent | SlackTurnToolResultEvent | SlackTurnToolErrorEvent | SlackTurnSubagentStartEvent | SlackTurnSubagentEventEvent | SlackTurnSubagentCompleteEvent | SlackTurnSubagentErrorEvent | SlackTurnStatusEvent | SlackTurnCompleteEvent | SlackTurnErrorEvent | SlackTurnApprovalRequestEvent | SlackTurnApprovalResolvedEvent | SlackTurnHumanInputRequestEvent | SlackTurnHumanInputResolvedEvent;
|
|
115
|
-
|
|
116
|
-
/**
|
|
117
|
-
* Event-bridge configuration. The bridge is mode-aware (progressive,
|
|
118
|
-
* accumulate, chat-stream) and these options control formatting, status
|
|
119
|
-
* propagation, interactive-request handling, and chat-stream finalization.
|
|
120
|
-
*/
|
|
121
|
-
|
|
122
|
-
type ApprovalRequest = SlackTurnApprovalRequestEvent["request"];
|
|
123
|
-
type HumanInputRequest = SlackTurnHumanInputRequestEvent["request"];
|
|
124
|
-
interface SlackEventBridgeOptions {
|
|
125
|
-
showReasoning: boolean;
|
|
126
|
-
/** Render root-agent tool rows/status updates. */
|
|
127
|
-
showToolUsage: boolean;
|
|
128
|
-
/** Render subagent child tool rows in the parent Slack task timeline. */
|
|
129
|
-
showSubagentToolUsage: boolean;
|
|
130
|
-
/** Include full subagent completion output in the subagent task row. */
|
|
131
|
-
showSubagentResultInTask: boolean;
|
|
132
|
-
formatToolTitle?: (toolName: string) => string;
|
|
133
|
-
formatToolUpdate: (toolName: string) => string;
|
|
134
|
-
formatToolDetails?: (event: SlackTurnToolStartEvent) => string | undefined;
|
|
135
|
-
/**
|
|
136
|
-
* Format the completed tool output shown in Slack task rows.
|
|
137
|
-
*
|
|
138
|
-
* Return `undefined` to use the default generic formatter. Return `null` to
|
|
139
|
-
* intentionally omit task-row output for this tool result.
|
|
140
|
-
*/
|
|
141
|
-
formatToolResultOutput?: (event: SlackTurnToolResultEvent) => string | null | undefined;
|
|
142
|
-
formatToolError: (toolName: string, error: string) => string;
|
|
143
|
-
formatReasoningUpdate: () => string;
|
|
144
|
-
formatMessageText: (text: string) => string;
|
|
145
|
-
streamingMode: "progressive" | "accumulate" | "chat-stream";
|
|
146
|
-
progressiveUpdateThreshold: number;
|
|
147
|
-
progressiveUpdateIntervalMs: number;
|
|
148
|
-
chatStreamBufferSize: number;
|
|
149
|
-
/**
|
|
150
|
-
* Maximum number of Slack task-update chunks the bridge will append to a
|
|
151
|
-
* single chat stream. Task rows are a bounded UI projection, not a durable
|
|
152
|
-
* event log.
|
|
153
|
-
*/
|
|
154
|
-
maxTaskUpdates: number;
|
|
155
|
-
/**
|
|
156
|
-
* Maximum cumulative characters from task titles/details/output that the
|
|
157
|
-
* bridge will append to one chat stream.
|
|
158
|
-
*/
|
|
159
|
-
maxTaskUpdateTextChars: number;
|
|
160
|
-
/**
|
|
161
|
-
* Maximum characters for a single task details/output field.
|
|
162
|
-
*/
|
|
163
|
-
maxTaskUpdateFieldChars: number;
|
|
164
|
-
interactiveMode: "message-and-error" | "ignore";
|
|
165
|
-
handleInteractiveRequest?: SlackEventInteractiveRequestHandler;
|
|
166
|
-
formatApprovalRequired: (request: ApprovalRequest) => string;
|
|
167
|
-
formatHumanInputRequired: (request: HumanInputRequest) => string;
|
|
168
|
-
/**
|
|
169
|
-
* Optional hook called whenever the bridge's status label changes — used by
|
|
170
|
-
* the assistant bridge to update the assistant pane's status line via
|
|
171
|
-
* `assistant.threads.setStatus`. Errors are swallowed by the caller.
|
|
172
|
-
*/
|
|
173
|
-
onStatusChange?: (label: string, event: SlackTurnEvent | undefined) => void | Promise<void>;
|
|
174
|
-
/**
|
|
175
|
-
* Optional final-args passthrough for `chatStream.stop(...)`. When the
|
|
176
|
-
* bridge stops the chat stream on `complete`, these args (e.g. final
|
|
177
|
-
* `blocks` for a feedback widget) are merged into the `stop` call. The
|
|
178
|
-
* existing `markdown_text` final-text fallback always wins on text fields.
|
|
179
|
-
*/
|
|
180
|
-
chatStreamFinalArgs?: {
|
|
181
|
-
blocks?: unknown[];
|
|
182
|
-
} & Record<string, unknown>;
|
|
183
|
-
/**
|
|
184
|
-
* Optional post-processing hook for publishing a rich artifact from the final
|
|
185
|
-
* accumulated response, such as a Slack Canvas for long answers.
|
|
186
|
-
*/
|
|
187
|
-
publishFinalResponseArtifact?: SlackFinalResponseArtifactPublisher;
|
|
188
|
-
/**
|
|
189
|
-
* Controls whether artifact publication is additive or becomes the primary
|
|
190
|
-
* final-answer surface.
|
|
191
|
-
*
|
|
192
|
-
* - `supplemental`: finalize the Slack text normally, then publish artifact.
|
|
193
|
-
* - `replace`: publish artifact first and use a compact Slack final message.
|
|
194
|
-
*
|
|
195
|
-
* @default "supplemental"
|
|
196
|
-
*/
|
|
197
|
-
finalResponseArtifactMode?: SlackFinalResponseArtifactDeliveryMode;
|
|
198
|
-
/**
|
|
199
|
-
* When replacement mode is active, continue streaming text up to this many
|
|
200
|
-
* raw characters, then suppress further text deltas and publish the full
|
|
201
|
-
* answer as an artifact at completion. This preserves normal short-answer
|
|
202
|
-
* streaming without flooding Slack for long answers.
|
|
203
|
-
*
|
|
204
|
-
* @default 4000
|
|
205
|
-
*/
|
|
206
|
-
finalResponseArtifactStreamThreshold?: number;
|
|
207
|
-
/**
|
|
208
|
-
* Notice appended when replacement mode suppresses the remaining text stream.
|
|
209
|
-
*/
|
|
210
|
-
formatFinalResponseArtifactContinuationNotice?: (context: Pick<SlackFinalResponseArtifactContext, "text" | "formattedText">) => string;
|
|
211
|
-
/**
|
|
212
|
-
* Final compact message used when an artifact replaces the full Slack text.
|
|
213
|
-
*/
|
|
214
|
-
formatFinalResponseArtifactMessage?: (result: SlackFinalResponseArtifactResult, context: SlackFinalResponseArtifactContext) => string;
|
|
215
|
-
/**
|
|
216
|
-
* Called when `publishFinalResponseArtifact` throws. Errors from this hook
|
|
217
|
-
* are swallowed so artifact publication cannot break a completed turn.
|
|
218
|
-
*/
|
|
219
|
-
onFinalResponseArtifactError?: (error: unknown, context: SlackFinalResponseArtifactContext) => void | Promise<void>;
|
|
220
|
-
}
|
|
221
|
-
declare function resolveSlackEventBridgeOptions(partial: Partial<SlackEventBridgeOptions>): SlackEventBridgeOptions;
|
|
222
|
-
|
|
223
9
|
/**
|
|
224
10
|
* Event bridge — maps a runtime-neutral `SlackTurnEvent` stream to a Slack
|
|
225
11
|
* conversation via a `SlackResponseSink`.
|
|
@@ -257,4 +43,4 @@ declare class UnsupportedSlackInteractiveRequestError extends Error {
|
|
|
257
43
|
constructor(kind: "approval" | "human-input", requestId: string, message: string);
|
|
258
44
|
}
|
|
259
45
|
|
|
260
|
-
export {
|
|
46
|
+
export { SlackEventBridgeOptions, SlackTurnEvent, UnsupportedSlackInteractiveRequestError, bridgeSlackTurnEventsToSlack };
|