@cuylabs/channel-slack 0.10.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.
- package/README.md +15 -2
- 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/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/reference/exports.md +5 -1
- package/package.json +23 -3
- package/dist/chunk-ISOMBQXE.js +0 -89
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 };
|
package/dist/socket.d.ts
ADDED
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
import { App } from '@slack/bolt';
|
|
2
|
+
import { C as CreateSlackSocketBoltAppOptions } from './bolt-app-BM0tiL7c.js';
|
|
3
|
+
import { e as SlackDirectAuthOptions, d as SlackDirectAuthMode } from './types-B9NfCVrk.js';
|
|
4
|
+
import { S as SlackAssistantBridge, C as CreateSlackAssistantBridgeOptions, d as SlackAssistantFeedbackConfig } from './options-DQacQDmD.js';
|
|
5
|
+
import { SlackAppSurfaceOptions } from './app-surface.js';
|
|
6
|
+
import { SlackFeedbackHandler } from './feedback/index.js';
|
|
7
|
+
import 'node:http';
|
|
8
|
+
import '@slack/web-api';
|
|
9
|
+
import './turn-BGAXddH_.js';
|
|
10
|
+
import './activity-ByrD9Ftr.js';
|
|
11
|
+
import './interactive-CbKYkkc_.js';
|
|
12
|
+
import './formatting-C-kwQseI.js';
|
|
13
|
+
import './options-B0xQCaez.js';
|
|
14
|
+
import './types-C8nkPuD4.js';
|
|
15
|
+
import './types-Cywfj8Mj.js';
|
|
16
|
+
import './logging-Bl3HfcC8.js';
|
|
17
|
+
import './types-wLZzyI9r.js';
|
|
18
|
+
import '@slack/types';
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* Socket Mode helpers for direct Slack.
|
|
22
|
+
*
|
|
23
|
+
* Slack's Socket Mode is the recommended local-development transport because
|
|
24
|
+
* it does not need a public webhook URL. The starter agent in
|
|
25
|
+
* `bolt-js-starter-agent` uses it for that reason. These helpers mirror the
|
|
26
|
+
* HTTP/Express mounts for the Socket Mode case so application code stays
|
|
27
|
+
* identical across transports.
|
|
28
|
+
*
|
|
29
|
+
* @example
|
|
30
|
+
* ```ts
|
|
31
|
+
* import { mountSlackAssistantSocket } from "@cuylabs/channel-slack/socket";
|
|
32
|
+
*
|
|
33
|
+
* await mountSlackAssistantSocket({
|
|
34
|
+
* source: agent,
|
|
35
|
+
* appToken: process.env.SLACK_APP_TOKEN, // xapp-...
|
|
36
|
+
* botToken: process.env.SLACK_BOT_TOKEN, // xoxb-...
|
|
37
|
+
* getSuggestedPrompts: () => ({
|
|
38
|
+
* prompts: [
|
|
39
|
+
* { title: "Roll dice", message: "Roll 2d20" },
|
|
40
|
+
* { title: "Brainstorm", message: "Help me brainstorm a launch plan" },
|
|
41
|
+
* ],
|
|
42
|
+
* }),
|
|
43
|
+
* });
|
|
44
|
+
* ```
|
|
45
|
+
*/
|
|
46
|
+
|
|
47
|
+
interface MountSlackAssistantSocketOptions extends Omit<CreateSlackAssistantBridgeOptions, "feedback"> {
|
|
48
|
+
/**
|
|
49
|
+
* Slack app-level token (`xapp-...`) with `connections:write` scope.
|
|
50
|
+
* @default process.env.SLACK_APP_TOKEN
|
|
51
|
+
*/
|
|
52
|
+
appToken?: string;
|
|
53
|
+
/**
|
|
54
|
+
* Slack bot token (`xoxb-...`) for the bot user in single-workspace mode.
|
|
55
|
+
* @default process.env.SLACK_BOT_TOKEN
|
|
56
|
+
*/
|
|
57
|
+
botToken?: string;
|
|
58
|
+
/**
|
|
59
|
+
* Direct-mode auth config (single-workspace, OAuth, custom).
|
|
60
|
+
*
|
|
61
|
+
* Socket Mode still requires `appToken`; OAuth/custom authorize only change
|
|
62
|
+
* how Bolt resolves workspace bot/user tokens once events arrive.
|
|
63
|
+
*/
|
|
64
|
+
auth?: SlackDirectAuthOptions;
|
|
65
|
+
/**
|
|
66
|
+
* Additional Bolt `App` options. Socket/auth fields are controlled by this
|
|
67
|
+
* helper and cannot be overridden. In OAuth Socket Mode, use `port` here to
|
|
68
|
+
* control the small HTTP server Bolt starts for install/callback routes.
|
|
69
|
+
*/
|
|
70
|
+
boltAppOptions?: CreateSlackSocketBoltAppOptions["boltAppOptions"];
|
|
71
|
+
/**
|
|
72
|
+
* Additional native Socket Mode receiver options. Use this for websocket
|
|
73
|
+
* health tuning such as ping timeouts and reconnect behavior.
|
|
74
|
+
*/
|
|
75
|
+
socketModeReceiverOptions?: CreateSlackSocketBoltAppOptions["socketModeReceiverOptions"];
|
|
76
|
+
/**
|
|
77
|
+
* Feedback config. Pass `false` to omit the feedback block. Pass an object
|
|
78
|
+
* to override action ids, button labels, or the handler.
|
|
79
|
+
*/
|
|
80
|
+
feedback?: SlackAssistantFeedbackConfig | false;
|
|
81
|
+
/**
|
|
82
|
+
* Convenience shorthand: `onFeedback: handler` is equivalent to
|
|
83
|
+
* `feedback: { onFeedback: handler }`. Ignored if `feedback` is set.
|
|
84
|
+
*/
|
|
85
|
+
onFeedback?: SlackFeedbackHandler;
|
|
86
|
+
/**
|
|
87
|
+
* Whether to call `app.start()` automatically. When `false`, callers own
|
|
88
|
+
* the lifecycle and must call `result.boltApp.start()` themselves.
|
|
89
|
+
* @default true
|
|
90
|
+
*/
|
|
91
|
+
start?: boolean;
|
|
92
|
+
}
|
|
93
|
+
interface MountSlackAssistantSocketResult {
|
|
94
|
+
boltApp: App;
|
|
95
|
+
bridge: SlackAssistantBridge;
|
|
96
|
+
authMode: SlackDirectAuthMode;
|
|
97
|
+
}
|
|
98
|
+
interface MountSlackAppSocketOptions extends SlackAppSurfaceOptions {
|
|
99
|
+
/**
|
|
100
|
+
* Slack app-level token (`xapp-...`) with `connections:write` scope.
|
|
101
|
+
* @default process.env.SLACK_APP_TOKEN
|
|
102
|
+
*/
|
|
103
|
+
appToken?: string;
|
|
104
|
+
/**
|
|
105
|
+
* Slack bot token (`xoxb-...`) for the bot user in single-workspace mode.
|
|
106
|
+
* @default process.env.SLACK_BOT_TOKEN
|
|
107
|
+
*/
|
|
108
|
+
botToken?: string;
|
|
109
|
+
/**
|
|
110
|
+
* Direct-mode auth config (single-workspace, OAuth, custom).
|
|
111
|
+
*
|
|
112
|
+
* Socket Mode still requires `appToken`; OAuth/custom authorize only change
|
|
113
|
+
* how Bolt resolves workspace bot/user tokens once events arrive.
|
|
114
|
+
*/
|
|
115
|
+
auth?: SlackDirectAuthOptions;
|
|
116
|
+
/**
|
|
117
|
+
* Additional Bolt `App` options. Socket/auth fields are controlled by this
|
|
118
|
+
* helper and cannot be overridden. In OAuth Socket Mode, use `port` here to
|
|
119
|
+
* control the small HTTP server Bolt starts for install/callback routes.
|
|
120
|
+
*/
|
|
121
|
+
boltAppOptions?: CreateSlackSocketBoltAppOptions["boltAppOptions"];
|
|
122
|
+
/**
|
|
123
|
+
* Additional native Socket Mode receiver options. Use this for websocket
|
|
124
|
+
* health tuning such as ping timeouts and reconnect behavior.
|
|
125
|
+
*/
|
|
126
|
+
socketModeReceiverOptions?: CreateSlackSocketBoltAppOptions["socketModeReceiverOptions"];
|
|
127
|
+
/**
|
|
128
|
+
* Whether to call `app.start()` automatically. When `false`, callers own
|
|
129
|
+
* the lifecycle and must call `result.boltApp.start()` themselves.
|
|
130
|
+
* @default true
|
|
131
|
+
*/
|
|
132
|
+
start?: boolean;
|
|
133
|
+
}
|
|
134
|
+
interface MountSlackAppSocketResult {
|
|
135
|
+
boltApp: App;
|
|
136
|
+
bridge: SlackAssistantBridge;
|
|
137
|
+
authMode: SlackDirectAuthMode;
|
|
138
|
+
}
|
|
139
|
+
declare function mountSlackAssistantSocket(options: MountSlackAssistantSocketOptions): Promise<MountSlackAssistantSocketResult>;
|
|
140
|
+
declare function mountSlackAppSocket(options: MountSlackAppSocketOptions): Promise<MountSlackAppSocketResult>;
|
|
141
|
+
|
|
142
|
+
export { type MountSlackAppSocketOptions, type MountSlackAppSocketResult, type MountSlackAssistantSocketOptions, type MountSlackAssistantSocketResult, mountSlackAppSocket, mountSlackAssistantSocket };
|
package/dist/socket.js
ADDED
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import {
|
|
2
|
+
createSlackSocketBoltApp
|
|
3
|
+
} from "./chunk-73QXT7MA.js";
|
|
4
|
+
import "./chunk-S3SWPYXJ.js";
|
|
5
|
+
import {
|
|
6
|
+
installSlackAppSurface
|
|
7
|
+
} from "./chunk-LFQCINHI.js";
|
|
8
|
+
import {
|
|
9
|
+
createSlackAssistantBridge
|
|
10
|
+
} from "./chunk-Q6YX7HHK.js";
|
|
11
|
+
import "./chunk-RHOIVQLD.js";
|
|
12
|
+
import "./chunk-IRFKUPJN.js";
|
|
13
|
+
import "./chunk-RTDLIYEE.js";
|
|
14
|
+
import "./chunk-IAQXQESO.js";
|
|
15
|
+
import "./chunk-37RN2YUI.js";
|
|
16
|
+
import "./chunk-3KP3CBCC.js";
|
|
17
|
+
import "./chunk-FPCE5V5Y.js";
|
|
18
|
+
import "./chunk-6WHFQUYQ.js";
|
|
19
|
+
|
|
20
|
+
// src/socket.ts
|
|
21
|
+
async function mountSlackAssistantSocket(options) {
|
|
22
|
+
const {
|
|
23
|
+
appToken: appTokenOption,
|
|
24
|
+
botToken: botTokenOption,
|
|
25
|
+
auth,
|
|
26
|
+
boltAppOptions,
|
|
27
|
+
socketModeReceiverOptions,
|
|
28
|
+
feedback: feedbackOption,
|
|
29
|
+
onFeedback,
|
|
30
|
+
start,
|
|
31
|
+
...bridgeOptions
|
|
32
|
+
} = options;
|
|
33
|
+
const { boltApp, authMode } = await createSlackSocketBoltApp({
|
|
34
|
+
appToken: appTokenOption,
|
|
35
|
+
botToken: botTokenOption,
|
|
36
|
+
auth,
|
|
37
|
+
boltAppOptions,
|
|
38
|
+
socketModeReceiverOptions
|
|
39
|
+
});
|
|
40
|
+
const feedback = feedbackOption !== void 0 ? feedbackOption : onFeedback ? { onFeedback } : void 0;
|
|
41
|
+
const bridge = createSlackAssistantBridge({
|
|
42
|
+
...bridgeOptions,
|
|
43
|
+
...feedback !== void 0 ? { feedback } : {}
|
|
44
|
+
});
|
|
45
|
+
bridge.install(boltApp);
|
|
46
|
+
if (start !== false) {
|
|
47
|
+
await boltApp.start();
|
|
48
|
+
}
|
|
49
|
+
return { boltApp, bridge, authMode };
|
|
50
|
+
}
|
|
51
|
+
async function mountSlackAppSocket(options) {
|
|
52
|
+
const {
|
|
53
|
+
appToken: appTokenOption,
|
|
54
|
+
botToken: botTokenOption,
|
|
55
|
+
auth,
|
|
56
|
+
boltAppOptions,
|
|
57
|
+
socketModeReceiverOptions,
|
|
58
|
+
start,
|
|
59
|
+
...surfaceOptions
|
|
60
|
+
} = options;
|
|
61
|
+
const { boltApp, authMode } = await createSlackSocketBoltApp({
|
|
62
|
+
appToken: appTokenOption,
|
|
63
|
+
botToken: botTokenOption,
|
|
64
|
+
auth,
|
|
65
|
+
boltAppOptions,
|
|
66
|
+
socketModeReceiverOptions
|
|
67
|
+
});
|
|
68
|
+
const { bridge } = installSlackAppSurface(boltApp, surfaceOptions);
|
|
69
|
+
if (start !== false) {
|
|
70
|
+
await boltApp.start();
|
|
71
|
+
}
|
|
72
|
+
return { boltApp, bridge, authMode };
|
|
73
|
+
}
|
|
74
|
+
export {
|
|
75
|
+
mountSlackAppSocket,
|
|
76
|
+
mountSlackAssistantSocket
|
|
77
|
+
};
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
export { CreateSlackBoltAppOptions, CreateSlackBoltAppResult, createSlackBoltApp, createSlackBoltApp as createSlackHttpBoltApp } from './http/index.js';
|
|
2
|
-
export {
|
|
2
|
+
export { C as CreateSlackSocketBoltAppOptions, a as CreateSlackSocketBoltAppResult, c as createSlackSocketBoltApp } from '../bolt-app-BM0tiL7c.js';
|
|
3
|
+
export { SlackSocketModePostgresLock, SlackSocketModePostgresLockClient, SlackSocketModePostgresLockOptions, SlackSocketModePostgresLockPool, SlackSocketModeProcessLock, SlackSocketModeProcessLockOptions, acquireSlackSocketModePostgresLock, acquireSlackSocketModeProcessLock } from './socket/index.js';
|
|
3
4
|
export { S as SlackSocketModeReceiverRuntimeOptions, a as SlackSocketModeRestartGuard, b as SlackSocketModeRuntime, c as SlackSocketModeRuntimeOptions, d as SlackSocketModeRuntimePolicy, e as createSlackSdkLogger, f as createSlackSocketModeRestartGuard, g as createSlackSocketModeRuntime, r as redactSlackSocketModeLogValue } from '../runtime-BNBHOZSQ.js';
|
|
4
5
|
export { LogLevel as SlackSdkLogLevel, Logger as SlackSdkLogger } from '@slack/bolt';
|
|
5
6
|
import 'express';
|
|
@@ -1,55 +1,10 @@
|
|
|
1
|
-
|
|
2
|
-
export { LogLevel as SlackSdkLogLevel, Logger as SlackSdkLogger } from '@slack/bolt';
|
|
3
|
-
import { e as SlackDirectAuthOptions, d as SlackDirectAuthMode } from '../../types-B9NfCVrk.js';
|
|
1
|
+
export { C as CreateSlackSocketBoltAppOptions, a as CreateSlackSocketBoltAppResult, c as createSlackSocketBoltApp } from '../../bolt-app-BM0tiL7c.js';
|
|
4
2
|
import { L as Logger } from '../../logging-Bl3HfcC8.js';
|
|
5
3
|
export { S as SlackSocketModeReceiverRuntimeOptions, a as SlackSocketModeRestartGuard, b as SlackSocketModeRuntime, c as SlackSocketModeRuntimeOptions, d as SlackSocketModeRuntimePolicy, e as createSlackSdkLogger, f as createSlackSocketModeRestartGuard, g as createSlackSocketModeRuntime, r as redactSlackSocketModeLogValue } from '../../runtime-BNBHOZSQ.js';
|
|
4
|
+
export { LogLevel as SlackSdkLogLevel, Logger as SlackSdkLogger } from '@slack/bolt';
|
|
5
|
+
import '../../types-B9NfCVrk.js';
|
|
6
6
|
import 'node:http';
|
|
7
7
|
|
|
8
|
-
/**
|
|
9
|
-
* `createSlackSocketBoltApp` — builds a Socket Mode Bolt `App` from the
|
|
10
|
-
* package's structured auth options. Mirrors `createSlackBoltApp` without
|
|
11
|
-
* owning any assistant/app surface mounting.
|
|
12
|
-
*/
|
|
13
|
-
|
|
14
|
-
type ControlledSocketBoltAppOption = "receiver" | "socketMode" | "appToken" | "token" | "authorize" | "botId" | "botUserId" | "clientId" | "clientSecret" | "stateSecret" | "redirectUri" | "installationStore" | "scopes" | "installerOptions";
|
|
15
|
-
type ControlledSocketModeReceiverOption = "appToken" | "clientId" | "clientSecret" | "stateSecret" | "redirectUri" | "installationStore" | "scopes" | "installerOptions" | "logger" | "logLevel";
|
|
16
|
-
interface CreateSlackSocketBoltAppOptions {
|
|
17
|
-
/**
|
|
18
|
-
* Slack app-level token (`xapp-...`) with `connections:write` scope.
|
|
19
|
-
* @default process.env.SLACK_APP_TOKEN
|
|
20
|
-
*/
|
|
21
|
-
appToken?: string;
|
|
22
|
-
/**
|
|
23
|
-
* Convenience override for single-workspace mode.
|
|
24
|
-
* @default process.env.SLACK_BOT_TOKEN
|
|
25
|
-
*/
|
|
26
|
-
botToken?: string;
|
|
27
|
-
/**
|
|
28
|
-
* Direct-mode auth configuration.
|
|
29
|
-
*
|
|
30
|
-
* - omit for single-workspace token mode
|
|
31
|
-
* - use `{ mode: "oauth", ... }` for Bolt-managed installs
|
|
32
|
-
* - use `{ mode: "authorize", authorize }` for external token resolution
|
|
33
|
-
*/
|
|
34
|
-
auth?: SlackDirectAuthOptions;
|
|
35
|
-
/**
|
|
36
|
-
* Additional Bolt `App` options passed after this package sets Socket Mode
|
|
37
|
-
* and auth. Use for logger/clientOptions and non-auth native Bolt config.
|
|
38
|
-
*/
|
|
39
|
-
boltAppOptions?: Partial<Omit<AppOptions, ControlledSocketBoltAppOption>>;
|
|
40
|
-
/**
|
|
41
|
-
* Additional native Socket Mode receiver options. Use this for websocket
|
|
42
|
-
* health tuning such as ping timeouts, reconnect behavior, and receiver
|
|
43
|
-
* error handling. Auth/OAuth fields stay controlled by this helper.
|
|
44
|
-
*/
|
|
45
|
-
socketModeReceiverOptions?: Partial<Omit<SocketModeReceiverOptions, ControlledSocketModeReceiverOption>>;
|
|
46
|
-
}
|
|
47
|
-
interface CreateSlackSocketBoltAppResult {
|
|
48
|
-
boltApp: App;
|
|
49
|
-
authMode: SlackDirectAuthMode;
|
|
50
|
-
}
|
|
51
|
-
declare function createSlackSocketBoltApp(options?: CreateSlackSocketBoltAppOptions): Promise<CreateSlackSocketBoltAppResult>;
|
|
52
|
-
|
|
53
8
|
interface SlackSocketModeProcessLockOptions {
|
|
54
9
|
appSlug: string;
|
|
55
10
|
appToken?: string;
|
|
@@ -91,4 +46,4 @@ interface SlackSocketModePostgresLock {
|
|
|
91
46
|
}
|
|
92
47
|
declare function acquireSlackSocketModePostgresLock({ appSlug, appToken, client, connectionString, enabled, logger, namespace, pool, }: SlackSocketModePostgresLockOptions): Promise<SlackSocketModePostgresLock | undefined>;
|
|
93
48
|
|
|
94
|
-
export { type
|
|
49
|
+
export { type SlackSocketModePostgresLock, type SlackSocketModePostgresLockClient, type SlackSocketModePostgresLockOptions, type SlackSocketModePostgresLockPool, type SlackSocketModeProcessLock, type SlackSocketModeProcessLockOptions, acquireSlackSocketModePostgresLock, acquireSlackSocketModeProcessLock };
|