@cuylabs/channel-slack-agent-core 0.1.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 (68) hide show
  1. package/LICENSE +201 -0
  2. package/README.md +80 -0
  3. package/dist/adapter-Cmd2C90g.d.ts +31 -0
  4. package/dist/adapter.d.ts +23 -0
  5. package/dist/adapter.js +13 -0
  6. package/dist/app-surface.d.ts +71 -0
  7. package/dist/app-surface.js +12 -0
  8. package/dist/app.d.ts +54 -0
  9. package/dist/app.js +14 -0
  10. package/dist/assistant.d.ts +19 -0
  11. package/dist/assistant.js +16 -0
  12. package/dist/bolt.d.ts +8 -0
  13. package/dist/bolt.js +10 -0
  14. package/dist/chunk-2SUAW6MV.js +12 -0
  15. package/dist/chunk-645NNJIM.js +12 -0
  16. package/dist/chunk-ANIZ5NT4.js +12 -0
  17. package/dist/chunk-BFUPAJON.js +662 -0
  18. package/dist/chunk-CYEBGC6G.js +77 -0
  19. package/dist/chunk-DHPD4XH5.js +827 -0
  20. package/dist/chunk-FDRQOG7Q.js +471 -0
  21. package/dist/chunk-GNXWTKQ6.js +48 -0
  22. package/dist/chunk-HFT2FXJP.js +12 -0
  23. package/dist/chunk-I2KLQ2HA.js +22 -0
  24. package/dist/chunk-IWUYIAY5.js +69 -0
  25. package/dist/chunk-IXY3BXU5.js +689 -0
  26. package/dist/chunk-JMLB7A2V.js +85 -0
  27. package/dist/chunk-K2E6A377.js +12 -0
  28. package/dist/chunk-M64Z6TYL.js +198 -0
  29. package/dist/chunk-NDVXBI7Z.js +12 -0
  30. package/dist/chunk-NIPAN4KA.js +76 -0
  31. package/dist/chunk-PX4RGO3N.js +12 -0
  32. package/dist/chunk-RFHXERNL.js +27 -0
  33. package/dist/chunk-VHGV66M7.js +12 -0
  34. package/dist/chunk-WO4BJMF3.js +82 -0
  35. package/dist/diagnostics.d.ts +1 -0
  36. package/dist/diagnostics.js +10 -0
  37. package/dist/express-assistant.d.ts +102 -0
  38. package/dist/express-assistant.js +12 -0
  39. package/dist/express.d.ts +98 -0
  40. package/dist/express.js +11 -0
  41. package/dist/feedback.d.ts +1 -0
  42. package/dist/feedback.js +10 -0
  43. package/dist/history.d.ts +1 -0
  44. package/dist/history.js +10 -0
  45. package/dist/index.d.ts +32 -0
  46. package/dist/index.js +202 -0
  47. package/dist/interactive-o_NZb-Xg.d.ts +47 -0
  48. package/dist/interactive.d.ts +30 -0
  49. package/dist/interactive.js +25 -0
  50. package/dist/mcp.d.ts +84 -0
  51. package/dist/mcp.js +9 -0
  52. package/dist/options-C7OYeNR-.d.ts +71 -0
  53. package/dist/options-Uf-qmQKN.d.ts +263 -0
  54. package/dist/policy.d.ts +1 -0
  55. package/dist/policy.js +10 -0
  56. package/dist/setup.d.ts +1 -0
  57. package/dist/setup.js +10 -0
  58. package/dist/shared.d.ts +129 -0
  59. package/dist/shared.js +20 -0
  60. package/dist/socket.d.ts +137 -0
  61. package/dist/socket.js +16 -0
  62. package/dist/targets.d.ts +1 -0
  63. package/dist/targets.js +10 -0
  64. package/dist/types-BqRzb_Cd.d.ts +346 -0
  65. package/dist/types-Crpil4kb.d.ts +136 -0
  66. package/dist/users.d.ts +1 -0
  67. package/dist/users.js +10 -0
  68. package/package.json +169 -0
@@ -0,0 +1,263 @@
1
+ import { AgentTurnSource, AgentEvent, Logger } from '@cuylabs/agent-core';
2
+ import { AssistantUserMessageMiddleware, AssistantThreadStartedMiddleware, Assistant, App } from '@slack/bolt';
3
+ import { WebClient } from '@slack/web-api';
4
+ import { SlackAuthContext, SlackAssistantThreadContext, SlackAssistantUtilities, SlackTurnPreparation, SlackAssistantTaskDisplayMode, SlackAssistantStatusUpdate, SlackAssistantSuggestedPrompts, SlackChatStreamStartArgs, SlackMessageFormattingOptions } from '@cuylabs/channel-slack/core';
5
+ import { h as SlackInteractiveRequestHandler } from './interactive-o_NZb-Xg.js';
6
+ import { S as SlackEventBridgeOptions } from './options-C7OYeNR-.js';
7
+ import { SlackFeedbackBlockOptions, SlackFeedbackHandler } from '@cuylabs/channel-slack/feedback';
8
+ import { ParsedAssistantUserMessage } from '@cuylabs/channel-slack/assistant';
9
+
10
+ /**
11
+ * Session strategies for the Bolt Assistant bridge.
12
+ *
13
+ * Slack assistant conversations are always threaded, including Assistant DMs,
14
+ * so the default assistant mapping keys sessions by `channel:thread_ts`. This
15
+ * intentionally differs from the shared channel adapter, where plain DMs use
16
+ * only the DM channel id.
17
+ */
18
+
19
+ type SlackAssistantSessionStrategy = "thread-aware" | "channel-id" | "user-per-thread";
20
+ declare function resolveAssistantSessionId(message: ParsedAssistantUserMessage, strategy: SlackAssistantSessionStrategy): string;
21
+
22
+ /**
23
+ * Public option types for the Slack Assistant bridge.
24
+ *
25
+ * Kept in a dedicated file so the lifecycle handlers, sink, and helpers can
26
+ * reference them without dragging the entire factory in.
27
+ */
28
+
29
+ type MaybePromise<T> = T | Promise<T>;
30
+ /**
31
+ * Structural alias for Bolt's `AssistantThreadContextStore`. Bolt does not
32
+ * re-export the type at the package root, so we redefine its `get` / `save`
33
+ * surface here. `DefaultThreadContextStore` from `@slack/bolt` (the bridge's
34
+ * default when no override is provided) implements the same shape.
35
+ */
36
+ interface SlackAssistantThreadContextStoreLike {
37
+ get: (args: any) => Promise<unknown>;
38
+ save: (args: any) => Promise<void>;
39
+ }
40
+ /**
41
+ * Loose alias for the runtime shape of arguments handed to assistant
42
+ * lifecycle middleware. Bolt does not re-export `AllAssistantMiddlewareArgs`
43
+ * either, but every handler we register receives a compatible record.
44
+ */
45
+ type AssistantLifecycleArgs = Parameters<AssistantUserMessageMiddleware>[0];
46
+ /** Args specifically for the `threadStarted` middleware. */
47
+ type AssistantThreadStartedArgs = Parameters<AssistantThreadStartedMiddleware>[0];
48
+ /**
49
+ * Context handed to `getSuggestedPrompts` / `getInitialReply` /
50
+ * `formatThreadTitle` when a Slack assistant thread starts.
51
+ */
52
+ interface SlackAssistantThreadStartedContext {
53
+ /** The raw `assistant_thread_started` event payload. */
54
+ event: AssistantThreadStartedArgs["payload"];
55
+ context: AssistantThreadStartedArgs["context"];
56
+ client: AssistantThreadStartedArgs["client"];
57
+ logger: AssistantThreadStartedArgs["logger"];
58
+ }
59
+ /**
60
+ * Context for per-message agent-side preparation. Returned values augment the
61
+ * agent turn but never replace the bridge's lifecycle calls (status, stream,
62
+ * feedback, etc.).
63
+ *
64
+ * `auth`, `threadContext`, and `assistant` are populated by the bridge before
65
+ * `prepareTurn` / `resolveSession` run, so callers can read tokens and the
66
+ * channel-of-origin metadata (or call `setStatus` etc. mid-prep) without
67
+ * reaching into `rawArgs`.
68
+ */
69
+ interface SlackAssistantUserMessageContext {
70
+ message: ParsedAssistantUserMessage;
71
+ sessionId: string;
72
+ /** Slack Web API client for direct Slack calls scoped to this turn. */
73
+ client: WebClient;
74
+ rawArgs: AssistantLifecycleArgs;
75
+ /** Slack auth + identity for the inbound request. */
76
+ auth: SlackAuthContext;
77
+ /**
78
+ * Bolt-resolved assistant thread context (channel of origin, etc.).
79
+ *
80
+ * Populated lazily on first read via `getThreadContext()`. The bridge
81
+ * resolves it once per turn and caches it so handlers don't have to.
82
+ */
83
+ threadContext: SlackAssistantThreadContext;
84
+ /**
85
+ * Assistant pane utilities (`setStatus`, `setSuggestedPrompts`, `setTitle`,
86
+ * `getThreadContext`, `saveThreadContext`).
87
+ */
88
+ assistant: SlackAssistantUtilities;
89
+ }
90
+ interface SlackAssistantTurnPreparation extends SlackTurnPreparation {
91
+ }
92
+ interface SlackAssistantStatusContext {
93
+ event: AgentEvent;
94
+ rawArgs: AssistantLifecycleArgs;
95
+ }
96
+ /**
97
+ * Configuration for the feedback block attached to assistant replies.
98
+ */
99
+ interface SlackAssistantFeedbackConfig extends SlackFeedbackBlockOptions {
100
+ /**
101
+ * Called after the user clicks a feedback button. The bridge already calls
102
+ * `ack()` and posts an ephemeral acknowledgement (configurable below).
103
+ */
104
+ onFeedback?: SlackFeedbackHandler;
105
+ /** Ephemeral text shown after a positive click. Set to `false` to skip. */
106
+ positiveAck?: string | false;
107
+ /** Ephemeral text shown after a negative click. */
108
+ negativeAck?: string | false;
109
+ }
110
+ interface CreateSlackAssistantBridgeOptions {
111
+ /**
112
+ * Source of agent turns. Any object satisfying `AgentTurnSource` works:
113
+ * `Agent`, `InProcessAgentServer`, a runtime bridge, or a stub.
114
+ */
115
+ source: AgentTurnSource;
116
+ /**
117
+ * Custom Bolt thread context store. Defaults to Bolt's
118
+ * `DefaultThreadContextStore` (metadata-on-message persistence).
119
+ */
120
+ threadContextStore?: SlackAssistantThreadContextStoreLike;
121
+ /**
122
+ * Session strategy for messages routed through the assistant.
123
+ * The default `"thread-aware"` strategy maps Slack Assistant threads to
124
+ * `${channelId}:${threadTs}`, including Assistant DM threads.
125
+ *
126
+ * @default "thread-aware"
127
+ */
128
+ sessionStrategy?: SlackAssistantSessionStrategy;
129
+ /**
130
+ * Optional explicit session resolver. Returning a falsy value falls back to
131
+ * the configured strategy.
132
+ */
133
+ resolveSession?: (request: SlackAssistantUserMessageContext) => MaybePromise<string | undefined>;
134
+ /**
135
+ * Optional per-turn preparation hook.
136
+ */
137
+ prepareTurn?: (request: SlackAssistantUserMessageContext) => MaybePromise<SlackAssistantTurnPreparation | undefined>;
138
+ /**
139
+ * Display mode for `client.chatStream`.
140
+ *
141
+ * - `"timeline"` (default) — linear streaming, best for chat answers.
142
+ * - `"plan"` — task list with `task_update` chunks. Pair with the agent
143
+ * emitting tool-start/tool-result events for the task UI.
144
+ */
145
+ taskDisplayMode?: SlackAssistantTaskDisplayMode;
146
+ /**
147
+ * Initial assistant pane status set immediately when a user message arrives.
148
+ *
149
+ * @default { status: "Thinking..." }
150
+ */
151
+ initialStatus?: SlackAssistantStatusUpdate | ((request: SlackAssistantUserMessageContext) => MaybePromise<SlackAssistantStatusUpdate | undefined>);
152
+ /**
153
+ * Map an AgentEvent to an assistant pane status update. Returning
154
+ * `undefined` keeps the previous status.
155
+ */
156
+ formatStatus?: (context: SlackAssistantStatusContext) => MaybePromise<SlackAssistantStatusUpdate | undefined>;
157
+ /**
158
+ * Suggested prompts shown when an assistant thread is opened.
159
+ */
160
+ getSuggestedPrompts?: (context: SlackAssistantThreadStartedContext) => MaybePromise<SlackAssistantSuggestedPrompts | undefined>;
161
+ /**
162
+ * Optional follow-up prompts surfaced after a successful turn completes.
163
+ *
164
+ * When provided and a non-empty result is returned, the bridge calls
165
+ * `assistant.threads.setSuggestedPrompts(...)` after the streaming reply
166
+ * has been finalized. Errors from this hook are logged and never break
167
+ * the turn.
168
+ */
169
+ getFollowUpPrompts?: (context: SlackAssistantUserMessageContext & {
170
+ finalText: string;
171
+ }) => MaybePromise<SlackAssistantSuggestedPrompts | undefined>;
172
+ /**
173
+ * Greeting message posted when an assistant thread is opened.
174
+ *
175
+ * @default "Hi, how can I help?"
176
+ */
177
+ getInitialReply?: (context: SlackAssistantThreadStartedContext) => MaybePromise<string | false | undefined>;
178
+ /**
179
+ * Called once per assistant turn to set the thread title via
180
+ * `assistant.threads.setTitle`. Return `undefined` to skip.
181
+ */
182
+ formatThreadTitle?: (request: SlackAssistantUserMessageContext) => MaybePromise<string | undefined>;
183
+ /**
184
+ * Feedback block configuration.
185
+ *
186
+ * - Object: builder + handler config (default).
187
+ * - `false`: omit the feedback block entirely.
188
+ */
189
+ feedback?: SlackAssistantFeedbackConfig | false;
190
+ /**
191
+ * Bridge options forwarded to `bridgeAgentEventsToSlack`. Streaming mode is
192
+ * pinned to `"chat-stream"` and cannot be overridden here.
193
+ */
194
+ showReasoning?: boolean;
195
+ /** Render root-agent tool rows/status updates. Defaults to true. */
196
+ showToolUsage?: boolean;
197
+ /** Render subagent child tool rows. Defaults to false. */
198
+ showSubagentToolUsage?: boolean;
199
+ /** Include full subagent final output in the task row. Defaults to false. */
200
+ showSubagentResultInTask?: boolean;
201
+ formatToolTitle?: (toolName: string) => string;
202
+ formatToolUpdate?: (toolName: string) => string;
203
+ formatToolDetails?: SlackEventBridgeOptions["formatToolDetails"];
204
+ formatToolError?: (toolName: string, error: string) => string;
205
+ formatReasoningUpdate?: () => string;
206
+ chatStreamBufferSize?: number;
207
+ maxTaskUpdates?: number;
208
+ maxTaskUpdateTextChars?: number;
209
+ maxTaskUpdateFieldChars?: number;
210
+ /**
211
+ * Start arguments merged into Slack's native chat stream.
212
+ *
213
+ * Use this for Slack-supported authorship fields such as `icon_emoji`,
214
+ * `icon_url`, and `username`. The bridge still owns channel, thread,
215
+ * recipient ids, task display mode, and buffer size.
216
+ */
217
+ chatStreamStartArgs?: SlackChatStreamStartArgs;
218
+ /**
219
+ * Final arguments merged into `chatStream.stop(...)`.
220
+ *
221
+ * Use this for static footer blocks such as content disclaimers. When
222
+ * feedback is enabled, the feedback block is appended after any configured
223
+ * blocks.
224
+ */
225
+ chatStreamFinalArgs?: SlackEventBridgeOptions["chatStreamFinalArgs"];
226
+ formatChatMarkdown?: SlackMessageFormattingOptions;
227
+ formatStreamError?: (error: Error) => string;
228
+ /**
229
+ * Slack-native renderer/resolver hook for approval and human-input
230
+ * requests. Return `true` after rendering/recording the request to keep the
231
+ * agent turn alive while an out-of-band Slack action resolves it.
232
+ */
233
+ handleInteractiveRequest?: SlackInteractiveRequestHandler;
234
+ /**
235
+ * Maximum time to let an assistant turn run before aborting the underlying
236
+ * `AgentTurnSource`.
237
+ *
238
+ * Set to `0` to disable the timeout.
239
+ *
240
+ * @default 120000
241
+ */
242
+ timeoutMs?: number;
243
+ /**
244
+ * Optional logger for bridge diagnostics.
245
+ */
246
+ logger?: Logger;
247
+ }
248
+ interface SlackAssistantBridge {
249
+ /** The Bolt `Assistant` middleware instance to pass to `app.assistant(...)`. */
250
+ assistant: Assistant;
251
+ /**
252
+ * Wire the assistant + feedback action handler onto a Bolt `App` in one
253
+ * call. Equivalent to `app.assistant(bridge.assistant)` plus the feedback
254
+ * action registration when feedback is enabled.
255
+ */
256
+ install(app: App): void;
257
+ /**
258
+ * The resolved feedback action id, or `undefined` when feedback is disabled.
259
+ */
260
+ feedbackActionId?: string;
261
+ }
262
+
263
+ export { type AssistantLifecycleArgs as A, type CreateSlackAssistantBridgeOptions as C, type MaybePromise as M, type SlackAssistantBridge as S, type AssistantThreadStartedArgs as a, type SlackAssistantFeedbackConfig as b, type SlackAssistantSessionStrategy as c, type SlackAssistantStatusContext as d, type SlackAssistantThreadContextStoreLike as e, type SlackAssistantThreadStartedContext as f, type SlackAssistantTurnPreparation as g, type SlackAssistantUserMessageContext as h, resolveAssistantSessionId as r };
@@ -0,0 +1 @@
1
+ export * from '@cuylabs/channel-slack/policy';
package/dist/policy.js ADDED
@@ -0,0 +1,10 @@
1
+ import {
2
+ policy_exports
3
+ } from "./chunk-2SUAW6MV.js";
4
+ import {
5
+ __reExport
6
+ } from "./chunk-I2KLQ2HA.js";
7
+
8
+ // src/policy.ts
9
+ var policy_exports2 = {};
10
+ __reExport(policy_exports2, policy_exports);
@@ -0,0 +1 @@
1
+ export * from '@cuylabs/channel-slack/setup';
package/dist/setup.js ADDED
@@ -0,0 +1,10 @@
1
+ import {
2
+ setup_exports
3
+ } from "./chunk-645NNJIM.js";
4
+ import {
5
+ __reExport
6
+ } from "./chunk-I2KLQ2HA.js";
7
+
8
+ // src/setup.ts
9
+ var setup_exports2 = {};
10
+ __reExport(setup_exports2, setup_exports);
@@ -0,0 +1,129 @@
1
+ import { SlackAmbientTurnContext } from '@cuylabs/channel-slack/core';
2
+ export * from '@cuylabs/channel-slack/core';
3
+ import { AgentEvent, AgentContextFragmentBuildContext, AgentContextFragmentInput, AgentContextFragmentKind, AgentContextFragmentRole, AgentContextFragmentPlacement, AgentContextFragmentLifetime, AgentContextFragmentBudgetBehavior, AgentMiddleware } from '@cuylabs/agent-core';
4
+ import { S as SlackEventBridgeOptions } from './options-C7OYeNR-.js';
5
+ export { r as resolveSlackEventBridgeOptions } from './options-C7OYeNR-.js';
6
+ import './interactive-o_NZb-Xg.js';
7
+
8
+ /**
9
+ * Slack response-sink contracts consumed by the event bridge.
10
+ *
11
+ * The adapter constructs a `SlackResponseSink` from the Bolt `say` function
12
+ * and `WebClient` instance available in each handler. Keeping the sink
13
+ * interface separate makes the bridge testable without a live Slack
14
+ * connection.
15
+ */
16
+ type SlackStreamTaskStatus = "pending" | "in_progress" | "complete" | "error";
17
+ type SlackStreamChunk = {
18
+ type: "markdown_text";
19
+ text: string;
20
+ } | {
21
+ type: "plan_update";
22
+ title: string;
23
+ } | {
24
+ type: "task_update";
25
+ id: string;
26
+ title: string;
27
+ status: SlackStreamTaskStatus;
28
+ details?: string;
29
+ output?: string;
30
+ };
31
+ interface SlackChatStream {
32
+ append(args: {
33
+ markdown_text?: string;
34
+ chunks?: SlackStreamChunk[];
35
+ }): Promise<unknown>;
36
+ stop(args?: {
37
+ markdown_text?: string;
38
+ chunks?: SlackStreamChunk[];
39
+ }): Promise<unknown>;
40
+ }
41
+ /**
42
+ * Minimal Slack posting interface consumed by the event bridge.
43
+ */
44
+ interface SlackResponseSink {
45
+ /**
46
+ * Post a new message to the channel / thread.
47
+ * Returns the channel ID and message timestamp needed for updates.
48
+ */
49
+ postMessage(text: string): Promise<{
50
+ channel: string;
51
+ ts: string;
52
+ }>;
53
+ /**
54
+ * Update an existing message by channel + ts.
55
+ */
56
+ updateMessage(channel: string, ts: string, text: string): Promise<void>;
57
+ /**
58
+ * Create a native Slack chat stream. Required when `streamingMode` is
59
+ * `"chat-stream"`.
60
+ */
61
+ createChatStream?(options: {
62
+ bufferSize: number;
63
+ }): SlackChatStream;
64
+ }
65
+
66
+ /**
67
+ * Event bridge — maps an agent-core `AgentEvent` stream to a Slack
68
+ * conversation via a `SlackResponseSink`.
69
+ *
70
+ * | Mode | Behaviour |
71
+ * |----------------|--------------------------------------------------------|
72
+ * | `progressive` | Posts a placeholder, updates it as text accumulates. |
73
+ * | `accumulate` | Collects the full response then posts it in one shot. |
74
+ * | `chat-stream` | Uses Slack's native `chat.startStream` + append + stop |
75
+ *
76
+ * The three modes share enough state (full-response accumulator, status
77
+ * label, last-update offset) that they live in one function. Per-mode
78
+ * branches are clearly labelled inside the event loop.
79
+ */
80
+
81
+ /**
82
+ * Stream agent-core events to a Slack conversation via `SlackResponseSink`.
83
+ *
84
+ * @returns The full accumulated response text.
85
+ */
86
+ declare function bridgeAgentEventsToSlack(events: AsyncGenerator<AgentEvent>, sink: SlackResponseSink, options: SlackEventBridgeOptions): Promise<string>;
87
+
88
+ /**
89
+ * Interactive-request error type raised when an `approval-request` or
90
+ * `human-input-request` event reaches the Slack transport in a mode that
91
+ * does not support in-channel resolution.
92
+ *
93
+ * Hosts can catch this error to fall back to message-and-error mode or to
94
+ * route the request through a custom block / view flow. Future work will
95
+ * add a first-class Slack rendering path here.
96
+ */
97
+ declare class UnsupportedSlackInteractiveRequestError extends Error {
98
+ readonly kind: "approval" | "human-input";
99
+ readonly requestId: string;
100
+ constructor(kind: "approval" | "human-input", requestId: string, message: string);
101
+ }
102
+
103
+ declare const DEFAULT_SLACK_CONTEXT_FRAGMENT_KEY = "slackContextFragment";
104
+ interface SlackContextFragmentPayload extends Partial<Pick<AgentContextFragmentInput, "budgetBehavior" | "dedupeKey" | "kind" | "lifetime" | "maxChars" | "metadata" | "placement" | "role" | "source" | "title">> {
105
+ content: string;
106
+ }
107
+ interface SlackContextFragmentResolverContext {
108
+ slack: Readonly<SlackAmbientTurnContext>;
109
+ step: AgentContextFragmentBuildContext;
110
+ }
111
+ type SlackContextFragmentResolver = (context: SlackContextFragmentResolverContext) => AgentContextFragmentInput | SlackContextFragmentPayload | string | undefined | Promise<AgentContextFragmentInput | SlackContextFragmentPayload | string | undefined>;
112
+ interface SlackContextFragmentMiddlewareOptions {
113
+ name?: string;
114
+ contextKey?: string;
115
+ resolve?: SlackContextFragmentResolver;
116
+ kind?: AgentContextFragmentKind;
117
+ role?: AgentContextFragmentRole;
118
+ placement?: AgentContextFragmentPlacement;
119
+ lifetime?: AgentContextFragmentLifetime;
120
+ title?: string;
121
+ source?: string;
122
+ budgetBehavior?: AgentContextFragmentBudgetBehavior;
123
+ maxChars?: number;
124
+ dedupeKey?: string | ((context: SlackContextFragmentResolverContext) => string | undefined);
125
+ metadata?: Record<string, unknown> | ((context: SlackContextFragmentResolverContext) => Record<string, unknown> | undefined);
126
+ }
127
+ declare function createSlackContextFragmentMiddleware(options?: SlackContextFragmentMiddlewareOptions): AgentMiddleware;
128
+
129
+ export { DEFAULT_SLACK_CONTEXT_FRAGMENT_KEY, type SlackChatStream, type SlackContextFragmentMiddlewareOptions, type SlackContextFragmentPayload, type SlackContextFragmentResolver, type SlackContextFragmentResolverContext, SlackEventBridgeOptions, type SlackResponseSink, type SlackStreamChunk, type SlackStreamTaskStatus, UnsupportedSlackInteractiveRequestError, bridgeAgentEventsToSlack, createSlackContextFragmentMiddleware };
package/dist/shared.js ADDED
@@ -0,0 +1,20 @@
1
+ import {
2
+ DEFAULT_SLACK_CONTEXT_FRAGMENT_KEY,
3
+ createSlackContextFragmentMiddleware
4
+ } from "./chunk-NIPAN4KA.js";
5
+ import {
6
+ UnsupportedSlackInteractiveRequestError,
7
+ bridgeAgentEventsToSlack,
8
+ resolveSlackEventBridgeOptions
9
+ } from "./chunk-DHPD4XH5.js";
10
+ import "./chunk-I2KLQ2HA.js";
11
+
12
+ // src/shared.ts
13
+ export * from "@cuylabs/channel-slack/core";
14
+ export {
15
+ DEFAULT_SLACK_CONTEXT_FRAGMENT_KEY,
16
+ UnsupportedSlackInteractiveRequestError,
17
+ bridgeAgentEventsToSlack,
18
+ createSlackContextFragmentMiddleware,
19
+ resolveSlackEventBridgeOptions
20
+ };
@@ -0,0 +1,137 @@
1
+ import { App } from '@slack/bolt';
2
+ import { SlackDirectAuthOptions, CreateSlackSocketBoltAppOptions, SlackDirectAuthMode } from '@cuylabs/channel-slack/bolt';
3
+ import { S as SlackAssistantBridge, C as CreateSlackAssistantBridgeOptions, b as SlackAssistantFeedbackConfig } from './options-Uf-qmQKN.js';
4
+ import { SlackAgentAppSurfaceOptions } from './app-surface.js';
5
+ import { SlackFeedbackHandler } from '@cuylabs/channel-slack/feedback';
6
+ import '@cuylabs/agent-core';
7
+ import '@slack/web-api';
8
+ import '@cuylabs/channel-slack/core';
9
+ import './interactive-o_NZb-Xg.js';
10
+ import './options-C7OYeNR-.js';
11
+ import '@cuylabs/channel-slack/assistant';
12
+ import './types-BqRzb_Cd.js';
13
+ import './types-Crpil4kb.js';
14
+
15
+ /**
16
+ * Socket Mode helpers for direct Slack.
17
+ *
18
+ * Slack's Socket Mode is the recommended local-development transport because
19
+ * it does not need a public webhook URL. The starter agent in
20
+ * `bolt-js-starter-agent` uses it for that reason. These helpers mirror the
21
+ * HTTP/Express mounts for the Socket Mode case so application code stays
22
+ * identical across transports.
23
+ *
24
+ * @example
25
+ * ```ts
26
+ * import { mountSlackAssistantAgentSocket } from "@cuylabs/channel-slack-agent-core";
27
+ *
28
+ * await mountSlackAssistantAgentSocket({
29
+ * source: agent,
30
+ * appToken: process.env.SLACK_APP_TOKEN, // xapp-...
31
+ * botToken: process.env.SLACK_BOT_TOKEN, // xoxb-...
32
+ * getSuggestedPrompts: () => ({
33
+ * prompts: [
34
+ * { title: "Roll dice", message: "Roll 2d20" },
35
+ * { title: "Brainstorm", message: "Help me brainstorm a launch plan" },
36
+ * ],
37
+ * }),
38
+ * });
39
+ * ```
40
+ */
41
+
42
+ interface MountSlackAssistantAgentSocketOptions extends Omit<CreateSlackAssistantBridgeOptions, "feedback"> {
43
+ /**
44
+ * Slack app-level token (`xapp-...`) with `connections:write` scope.
45
+ * @default process.env.SLACK_APP_TOKEN
46
+ */
47
+ appToken?: string;
48
+ /**
49
+ * Slack bot token (`xoxb-...`) for the bot user in single-workspace mode.
50
+ * @default process.env.SLACK_BOT_TOKEN
51
+ */
52
+ botToken?: string;
53
+ /**
54
+ * Direct-mode auth config (single-workspace, OAuth, custom).
55
+ *
56
+ * Socket Mode still requires `appToken`; OAuth/custom authorize only change
57
+ * how Bolt resolves workspace bot/user tokens once events arrive.
58
+ */
59
+ auth?: SlackDirectAuthOptions;
60
+ /**
61
+ * Additional Bolt `App` options. Socket/auth fields are controlled by this
62
+ * helper and cannot be overridden. In OAuth Socket Mode, use `port` here to
63
+ * control the small HTTP server Bolt starts for install/callback routes.
64
+ */
65
+ boltAppOptions?: CreateSlackSocketBoltAppOptions["boltAppOptions"];
66
+ /**
67
+ * Additional native Socket Mode receiver options. Use this for websocket
68
+ * health tuning such as ping timeouts and reconnect behavior.
69
+ */
70
+ socketModeReceiverOptions?: CreateSlackSocketBoltAppOptions["socketModeReceiverOptions"];
71
+ /**
72
+ * Feedback config. Pass `false` to omit the feedback block. Pass an object
73
+ * to override action ids, button labels, or the handler.
74
+ */
75
+ feedback?: SlackAssistantFeedbackConfig | false;
76
+ /**
77
+ * Convenience shorthand: `onFeedback: handler` is equivalent to
78
+ * `feedback: { onFeedback: handler }`. Ignored if `feedback` is set.
79
+ */
80
+ onFeedback?: SlackFeedbackHandler;
81
+ /**
82
+ * Whether to call `app.start()` automatically. When `false`, callers own
83
+ * the lifecycle and must call `result.boltApp.start()` themselves.
84
+ * @default true
85
+ */
86
+ start?: boolean;
87
+ }
88
+ interface MountSlackAssistantAgentSocketResult {
89
+ boltApp: App;
90
+ bridge: SlackAssistantBridge;
91
+ authMode: SlackDirectAuthMode;
92
+ }
93
+ interface MountSlackAgentAppSocketOptions extends SlackAgentAppSurfaceOptions {
94
+ /**
95
+ * Slack app-level token (`xapp-...`) with `connections:write` scope.
96
+ * @default process.env.SLACK_APP_TOKEN
97
+ */
98
+ appToken?: string;
99
+ /**
100
+ * Slack bot token (`xoxb-...`) for the bot user in single-workspace mode.
101
+ * @default process.env.SLACK_BOT_TOKEN
102
+ */
103
+ botToken?: string;
104
+ /**
105
+ * Direct-mode auth config (single-workspace, OAuth, custom).
106
+ *
107
+ * Socket Mode still requires `appToken`; OAuth/custom authorize only change
108
+ * how Bolt resolves workspace bot/user tokens once events arrive.
109
+ */
110
+ auth?: SlackDirectAuthOptions;
111
+ /**
112
+ * Additional Bolt `App` options. Socket/auth fields are controlled by this
113
+ * helper and cannot be overridden. In OAuth Socket Mode, use `port` here to
114
+ * control the small HTTP server Bolt starts for install/callback routes.
115
+ */
116
+ boltAppOptions?: CreateSlackSocketBoltAppOptions["boltAppOptions"];
117
+ /**
118
+ * Additional native Socket Mode receiver options. Use this for websocket
119
+ * health tuning such as ping timeouts and reconnect behavior.
120
+ */
121
+ socketModeReceiverOptions?: CreateSlackSocketBoltAppOptions["socketModeReceiverOptions"];
122
+ /**
123
+ * Whether to call `app.start()` automatically. When `false`, callers own
124
+ * the lifecycle and must call `result.boltApp.start()` themselves.
125
+ * @default true
126
+ */
127
+ start?: boolean;
128
+ }
129
+ interface MountSlackAgentAppSocketResult {
130
+ boltApp: App;
131
+ bridge: SlackAssistantBridge;
132
+ authMode: SlackDirectAuthMode;
133
+ }
134
+ declare function mountSlackAssistantAgentSocket(options: MountSlackAssistantAgentSocketOptions): Promise<MountSlackAssistantAgentSocketResult>;
135
+ declare function mountSlackAgentAppSocket(options: MountSlackAgentAppSocketOptions): Promise<MountSlackAgentAppSocketResult>;
136
+
137
+ export { type MountSlackAgentAppSocketOptions, type MountSlackAgentAppSocketResult, type MountSlackAssistantAgentSocketOptions, type MountSlackAssistantAgentSocketResult, mountSlackAgentAppSocket, mountSlackAssistantAgentSocket };
package/dist/socket.js ADDED
@@ -0,0 +1,16 @@
1
+ import {
2
+ mountSlackAgentAppSocket,
3
+ mountSlackAssistantAgentSocket
4
+ } from "./chunk-IWUYIAY5.js";
5
+ import "./chunk-M64Z6TYL.js";
6
+ import "./chunk-BFUPAJON.js";
7
+ import "./chunk-VHGV66M7.js";
8
+ import "./chunk-FDRQOG7Q.js";
9
+ import "./chunk-GNXWTKQ6.js";
10
+ import "./chunk-DHPD4XH5.js";
11
+ import "./chunk-ANIZ5NT4.js";
12
+ import "./chunk-I2KLQ2HA.js";
13
+ export {
14
+ mountSlackAgentAppSocket,
15
+ mountSlackAssistantAgentSocket
16
+ };
@@ -0,0 +1 @@
1
+ export * from '@cuylabs/channel-slack/targets';
@@ -0,0 +1,10 @@
1
+ import {
2
+ targets_exports
3
+ } from "./chunk-K2E6A377.js";
4
+ import {
5
+ __reExport
6
+ } from "./chunk-I2KLQ2HA.js";
7
+
8
+ // src/targets.ts
9
+ var targets_exports2 = {};
10
+ __reExport(targets_exports2, targets_exports);