@cuylabs/channel-slack 0.9.0 → 0.11.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (40) hide show
  1. package/README.md +15 -2
  2. package/dist/adapter/index.d.ts +53 -0
  3. package/dist/adapter/index.js +13 -0
  4. package/dist/app-surface.d.ts +86 -0
  5. package/dist/app-surface.js +15 -0
  6. package/dist/app.d.ts +58 -0
  7. package/dist/app.js +86 -0
  8. package/dist/artifacts/index.d.ts +57 -3
  9. package/dist/artifacts/index.js +88 -0
  10. package/dist/assistant/index.d.ts +18 -53
  11. package/dist/assistant/index.js +15 -184
  12. package/dist/bolt-app-BM0tiL7c.d.ts +49 -0
  13. package/dist/{chunk-TWJGVDA2.js → chunk-37RN2YUI.js} +88 -1
  14. package/dist/chunk-IAQXQESO.js +1008 -0
  15. package/dist/chunk-LFQCINHI.js +187 -0
  16. package/dist/chunk-Q6YX7HHK.js +1062 -0
  17. package/dist/chunk-RHOIVQLD.js +127 -0
  18. package/dist/chunk-RTDLIYEE.js +446 -0
  19. package/dist/core.d.ts +5 -201
  20. package/dist/core.js +10 -12
  21. package/dist/feedback/index.d.ts +2 -2
  22. package/dist/feedback/index.js +5 -120
  23. package/dist/formatting-C-kwQseI.d.ts +25 -0
  24. package/dist/index.d.ts +8 -1
  25. package/dist/index.js +18 -12
  26. package/dist/interactive/index.d.ts +4 -91
  27. package/dist/options-B0xQCaez.d.ts +221 -0
  28. package/dist/options-DQacQDmD.d.ts +368 -0
  29. package/dist/runtime/index.d.ts +46 -0
  30. package/dist/runtime/index.js +10 -0
  31. package/dist/socket.d.ts +142 -0
  32. package/dist/socket.js +77 -0
  33. package/dist/transports/index.d.ts +2 -1
  34. package/dist/transports/socket/index.d.ts +4 -49
  35. package/dist/turn-BGAXddH_.d.ts +178 -0
  36. package/dist/types-Cywfj8Mj.d.ts +91 -0
  37. package/dist/types-wLZzyI9r.d.ts +375 -0
  38. package/docs/reference/exports.md +5 -1
  39. package/package.json +28 -3
  40. package/dist/chunk-ISOMBQXE.js +0 -89
@@ -0,0 +1,221 @@
1
+ import { d as SlackArtifactClient, g as SlackArtifactPublication } from './types-C8nkPuD4.js';
2
+ import { c as SlackInteractiveApprovalRequest, e as SlackInteractiveHumanInputRequest } from './types-Cywfj8Mj.js';
3
+ import { a as SlackEventInteractiveRequestHandler } from './interactive-CbKYkkc_.js';
4
+
5
+ interface SlackTurnSourceChatOptions {
6
+ abort?: AbortSignal;
7
+ system?: string;
8
+ }
9
+ interface SlackTurnSource {
10
+ chat(sessionId: string, message: string, options?: SlackTurnSourceChatOptions): AsyncGenerator<SlackTurnEvent>;
11
+ }
12
+ interface SlackFinalResponseArtifactContext {
13
+ text: string;
14
+ formattedText: string;
15
+ client: SlackArtifactClient;
16
+ channelId: string;
17
+ threadTs?: string;
18
+ }
19
+ interface SlackFinalResponseArtifactResult {
20
+ publication: SlackArtifactPublication;
21
+ }
22
+ type SlackFinalResponseArtifactDeliveryMode = "supplemental" | "replace";
23
+ type SlackFinalResponseArtifactPublisher = (context: SlackFinalResponseArtifactContext) => Promise<SlackFinalResponseArtifactResult | undefined>;
24
+ type SlackTurnStatus = "thinking" | "reasoning" | "calling-tool" | "waiting-approval" | "waiting-input" | "processing" | "error" | string;
25
+ interface SlackTurnEventBase {
26
+ type: string;
27
+ [key: string]: unknown;
28
+ }
29
+ interface SlackTurnTextStartEvent extends SlackTurnEventBase {
30
+ type: "text-start";
31
+ }
32
+ interface SlackTurnTextDeltaEvent extends SlackTurnEventBase {
33
+ type: "text-delta";
34
+ text: string;
35
+ }
36
+ interface SlackTurnTextEndEvent extends SlackTurnEventBase {
37
+ type: "text-end";
38
+ }
39
+ interface SlackTurnReasoningStartEvent extends SlackTurnEventBase {
40
+ type: "reasoning-start";
41
+ }
42
+ interface SlackTurnReasoningEndEvent extends SlackTurnEventBase {
43
+ type: "reasoning-end";
44
+ }
45
+ interface SlackTurnToolStartEvent extends SlackTurnEventBase {
46
+ type: "tool-start";
47
+ toolCallId: string;
48
+ toolName: string;
49
+ input?: unknown;
50
+ }
51
+ interface SlackTurnToolResultEvent extends SlackTurnEventBase {
52
+ type: "tool-result";
53
+ toolCallId: string;
54
+ toolName: string;
55
+ result?: unknown;
56
+ }
57
+ interface SlackTurnToolErrorEvent extends SlackTurnEventBase {
58
+ type: "tool-error";
59
+ toolCallId: string;
60
+ toolName: string;
61
+ error: string;
62
+ }
63
+ interface SlackTurnSubagentEventBase extends SlackTurnEventBase {
64
+ dispatchId: string;
65
+ role: string;
66
+ title?: string;
67
+ parentDispatchId?: string;
68
+ agentPath?: string;
69
+ depth?: number;
70
+ }
71
+ interface SlackTurnSubagentStartEvent extends SlackTurnSubagentEventBase {
72
+ type: "subagent-start";
73
+ }
74
+ interface SlackTurnSubagentEventEvent extends SlackTurnSubagentEventBase {
75
+ type: "subagent-event";
76
+ event: SlackTurnEvent;
77
+ }
78
+ interface SlackTurnSubagentCompleteEvent extends SlackTurnSubagentEventBase {
79
+ type: "subagent-complete";
80
+ output?: unknown;
81
+ }
82
+ interface SlackTurnSubagentErrorEvent extends SlackTurnSubagentEventBase {
83
+ type: "subagent-error";
84
+ error: string;
85
+ }
86
+ interface SlackTurnStatusEvent extends SlackTurnEventBase {
87
+ type: "status";
88
+ status: SlackTurnStatus;
89
+ }
90
+ interface SlackTurnCompleteEvent extends SlackTurnEventBase {
91
+ type: "complete";
92
+ output?: string;
93
+ }
94
+ interface SlackTurnErrorEvent extends SlackTurnEventBase {
95
+ type: "error";
96
+ error: unknown;
97
+ }
98
+ interface SlackTurnApprovalRequestEvent extends SlackTurnEventBase {
99
+ type: "approval-request";
100
+ request: SlackInteractiveApprovalRequest;
101
+ }
102
+ interface SlackTurnApprovalResolvedEvent extends SlackTurnEventBase {
103
+ type: "approval-resolved";
104
+ }
105
+ interface SlackTurnHumanInputRequestEvent extends SlackTurnEventBase {
106
+ type: "human-input-request";
107
+ request: SlackInteractiveHumanInputRequest;
108
+ }
109
+ interface SlackTurnHumanInputResolvedEvent extends SlackTurnEventBase {
110
+ type: "human-input-resolved";
111
+ }
112
+ type SlackTurnEvent = SlackTurnTextStartEvent | SlackTurnTextDeltaEvent | SlackTurnTextEndEvent | SlackTurnReasoningStartEvent | SlackTurnReasoningEndEvent | SlackTurnToolStartEvent | SlackTurnToolResultEvent | SlackTurnToolErrorEvent | SlackTurnSubagentStartEvent | SlackTurnSubagentEventEvent | SlackTurnSubagentCompleteEvent | SlackTurnSubagentErrorEvent | SlackTurnStatusEvent | SlackTurnCompleteEvent | SlackTurnErrorEvent | SlackTurnApprovalRequestEvent | SlackTurnApprovalResolvedEvent | SlackTurnHumanInputRequestEvent | SlackTurnHumanInputResolvedEvent;
113
+
114
+ /**
115
+ * Event-bridge configuration. The bridge is mode-aware (progressive,
116
+ * accumulate, chat-stream) and these options control formatting, status
117
+ * propagation, interactive-request handling, and chat-stream finalization.
118
+ */
119
+
120
+ type ApprovalRequest = SlackTurnApprovalRequestEvent["request"];
121
+ type HumanInputRequest = SlackTurnHumanInputRequestEvent["request"];
122
+ interface SlackEventBridgeOptions {
123
+ showReasoning: boolean;
124
+ /** Render root-agent tool rows/status updates. */
125
+ showToolUsage: boolean;
126
+ /** Render subagent child tool rows in the parent Slack task timeline. */
127
+ showSubagentToolUsage: boolean;
128
+ /** Include full subagent completion output in the subagent task row. */
129
+ showSubagentResultInTask: boolean;
130
+ formatToolTitle?: (toolName: string) => string;
131
+ formatToolUpdate: (toolName: string) => string;
132
+ formatToolDetails?: (event: SlackTurnToolStartEvent) => string | undefined;
133
+ /**
134
+ * Format the completed tool output shown in Slack task rows.
135
+ *
136
+ * Return `undefined` to use the default generic formatter. Return `null` to
137
+ * intentionally omit task-row output for this tool result.
138
+ */
139
+ formatToolResultOutput?: (event: SlackTurnToolResultEvent) => string | null | undefined;
140
+ formatToolError: (toolName: string, error: string) => string;
141
+ formatReasoningUpdate: () => string;
142
+ formatMessageText: (text: string) => string;
143
+ streamingMode: "progressive" | "accumulate" | "chat-stream";
144
+ progressiveUpdateThreshold: number;
145
+ progressiveUpdateIntervalMs: number;
146
+ chatStreamBufferSize: number;
147
+ /**
148
+ * Maximum number of Slack task-update chunks the bridge will append to a
149
+ * single chat stream. Task rows are a bounded UI projection, not a durable
150
+ * event log.
151
+ */
152
+ maxTaskUpdates: number;
153
+ /**
154
+ * Maximum cumulative characters from task titles/details/output that the
155
+ * bridge will append to one chat stream.
156
+ */
157
+ maxTaskUpdateTextChars: number;
158
+ /**
159
+ * Maximum characters for a single task details/output field.
160
+ */
161
+ maxTaskUpdateFieldChars: number;
162
+ interactiveMode: "message-and-error" | "ignore";
163
+ handleInteractiveRequest?: SlackEventInteractiveRequestHandler;
164
+ formatApprovalRequired: (request: ApprovalRequest) => string;
165
+ formatHumanInputRequired: (request: HumanInputRequest) => string;
166
+ /**
167
+ * Optional hook called whenever the bridge's status label changes — used by
168
+ * the assistant bridge to update the assistant pane's status line via
169
+ * `assistant.threads.setStatus`. Errors are swallowed by the caller.
170
+ */
171
+ onStatusChange?: (label: string, event: SlackTurnEvent | undefined) => void | Promise<void>;
172
+ /**
173
+ * Optional final-args passthrough for `chatStream.stop(...)`. When the
174
+ * bridge stops the chat stream on `complete`, these args (e.g. final
175
+ * `blocks` for a feedback widget) are merged into the `stop` call. The
176
+ * existing `markdown_text` final-text fallback always wins on text fields.
177
+ */
178
+ chatStreamFinalArgs?: {
179
+ blocks?: unknown[];
180
+ } & Record<string, unknown>;
181
+ /**
182
+ * Optional post-processing hook for publishing a rich artifact from the final
183
+ * accumulated response, such as a Slack Canvas for long answers.
184
+ */
185
+ publishFinalResponseArtifact?: SlackFinalResponseArtifactPublisher;
186
+ /**
187
+ * Controls whether artifact publication is additive or becomes the primary
188
+ * final-answer surface.
189
+ *
190
+ * - `supplemental`: finalize the Slack text normally, then publish artifact.
191
+ * - `replace`: publish artifact first and use a compact Slack final message.
192
+ *
193
+ * @default "supplemental"
194
+ */
195
+ finalResponseArtifactMode?: SlackFinalResponseArtifactDeliveryMode;
196
+ /**
197
+ * When replacement mode is active, continue streaming text up to this many
198
+ * raw characters, then suppress further text deltas and publish the full
199
+ * answer as an artifact at completion. This preserves normal short-answer
200
+ * streaming without flooding Slack for long answers.
201
+ *
202
+ * @default 4000
203
+ */
204
+ finalResponseArtifactStreamThreshold?: number;
205
+ /**
206
+ * Notice appended when replacement mode suppresses the remaining text stream.
207
+ */
208
+ formatFinalResponseArtifactContinuationNotice?: (context: Pick<SlackFinalResponseArtifactContext, "text" | "formattedText">) => string;
209
+ /**
210
+ * Final compact message used when an artifact replaces the full Slack text.
211
+ */
212
+ formatFinalResponseArtifactMessage?: (result: SlackFinalResponseArtifactResult, context: SlackFinalResponseArtifactContext) => string;
213
+ /**
214
+ * Called when `publishFinalResponseArtifact` throws. Errors from this hook
215
+ * are swallowed so artifact publication cannot break a completed turn.
216
+ */
217
+ onFinalResponseArtifactError?: (error: unknown, context: SlackFinalResponseArtifactContext) => void | Promise<void>;
218
+ }
219
+ declare function resolveSlackEventBridgeOptions(partial: Partial<SlackEventBridgeOptions>): SlackEventBridgeOptions;
220
+
221
+ export { type SlackTurnToolErrorEvent as A, type SlackTurnToolResultEvent as B, type SlackTurnToolStartEvent as C, resolveSlackEventBridgeOptions as D, type SlackEventBridgeOptions as S, type SlackFinalResponseArtifactContext as a, type SlackFinalResponseArtifactDeliveryMode as b, type SlackFinalResponseArtifactPublisher as c, type SlackFinalResponseArtifactResult as d, type SlackTurnApprovalRequestEvent as e, type SlackTurnApprovalResolvedEvent as f, type SlackTurnCompleteEvent as g, type SlackTurnErrorEvent as h, type SlackTurnEvent as i, type SlackTurnEventBase as j, type SlackTurnHumanInputRequestEvent as k, type SlackTurnHumanInputResolvedEvent as l, type SlackTurnReasoningEndEvent as m, type SlackTurnReasoningStartEvent as n, type SlackTurnSource as o, type SlackTurnSourceChatOptions as p, type SlackTurnStatus as q, type SlackTurnStatusEvent as r, type SlackTurnSubagentCompleteEvent as s, type SlackTurnSubagentErrorEvent as t, type SlackTurnSubagentEventBase as u, type SlackTurnSubagentEventEvent as v, type SlackTurnSubagentStartEvent as w, type SlackTurnTextDeltaEvent as x, type SlackTurnTextEndEvent as y, type SlackTurnTextStartEvent as z };
@@ -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 };
@@ -0,0 +1,46 @@
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';
3
+ import { SlackResponseSink } from '../responses/index.js';
4
+ import '../types-C8nkPuD4.js';
5
+ import '../types-Cywfj8Mj.js';
6
+ import '../interactive-CbKYkkc_.js';
7
+ import '../activity-ByrD9Ftr.js';
8
+
9
+ /**
10
+ * Event bridge — maps a runtime-neutral `SlackTurnEvent` stream to a Slack
11
+ * conversation via a `SlackResponseSink`.
12
+ *
13
+ * | Mode | Behaviour |
14
+ * |----------------|--------------------------------------------------------|
15
+ * | `progressive` | Posts a placeholder, updates it as text accumulates. |
16
+ * | `accumulate` | Collects the full response then posts it in one shot. |
17
+ * | `chat-stream` | Uses Slack's native `chat.startStream` + append + stop |
18
+ *
19
+ * The three modes share enough state (full-response accumulator, status
20
+ * label, last-update offset) that they live in one function. Per-mode
21
+ * branches are clearly labelled inside the event loop.
22
+ */
23
+
24
+ /**
25
+ * Stream runtime-neutral turn events to a Slack conversation via
26
+ * `SlackResponseSink`.
27
+ *
28
+ * @returns The full accumulated response text.
29
+ */
30
+ declare function bridgeSlackTurnEventsToSlack(events: AsyncGenerator<SlackTurnEvent>, sink: SlackResponseSink, options: SlackEventBridgeOptions): Promise<string>;
31
+
32
+ /**
33
+ * Interactive-request error type raised when an `approval-request` or
34
+ * `human-input-request` event reaches the Slack transport in a mode that
35
+ * does not support in-channel resolution.
36
+ *
37
+ * Hosts can catch this error to fall back to message-and-error mode, or install
38
+ * `createSlackInteractiveController` to render and resolve requests in Slack.
39
+ */
40
+ declare class UnsupportedSlackInteractiveRequestError extends Error {
41
+ readonly kind: "approval" | "human-input";
42
+ readonly requestId: string;
43
+ constructor(kind: "approval" | "human-input", requestId: string, message: string);
44
+ }
45
+
46
+ export { SlackEventBridgeOptions, SlackTurnEvent, UnsupportedSlackInteractiveRequestError, bridgeSlackTurnEventsToSlack };
@@ -0,0 +1,10 @@
1
+ import {
2
+ UnsupportedSlackInteractiveRequestError,
3
+ bridgeSlackTurnEventsToSlack,
4
+ resolveSlackEventBridgeOptions
5
+ } from "../chunk-IAQXQESO.js";
6
+ export {
7
+ UnsupportedSlackInteractiveRequestError,
8
+ bridgeSlackTurnEventsToSlack,
9
+ resolveSlackEventBridgeOptions
10
+ };