@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.
- 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-IAQXQESO.js +1008 -0
- 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 +8 -1
- package/dist/index.js +18 -12
- package/dist/interactive/index.d.ts +4 -91
- package/dist/options-B0xQCaez.d.ts +221 -0
- package/dist/options-DQacQDmD.d.ts +368 -0
- package/dist/runtime/index.d.ts +46 -0
- package/dist/runtime/index.js +10 -0
- 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-Cywfj8Mj.d.ts +91 -0
- package/dist/types-wLZzyI9r.d.ts +375 -0
- package/docs/reference/exports.md +5 -1
- package/package.json +28 -3
- package/dist/chunk-ISOMBQXE.js +0 -89
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 };
|
|
@@ -0,0 +1,178 @@
|
|
|
1
|
+
import { S as SlackActivityInfo, b as SlackUserIdentity } from './activity-ByrD9Ftr.js';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Slack auth context — credentials and identifiers resolved from the inbound
|
|
5
|
+
* request. **Sensitive**: see security note on `SlackAuthContext`.
|
|
6
|
+
*/
|
|
7
|
+
/**
|
|
8
|
+
* Slack credentials and identifiers resolved from the inbound request.
|
|
9
|
+
*
|
|
10
|
+
* Surfaced to `prepareTurn`, the ambient `currentSlackTurnContext()`, and the
|
|
11
|
+
* assistant message context so tools and middleware can call the Slack Web
|
|
12
|
+
* API or attach per-user OAuth tokens to MCP servers (see
|
|
13
|
+
* `createSlackMcpServerConfig`).
|
|
14
|
+
*
|
|
15
|
+
* Security: `botToken` and `userToken` are secrets. Do not include this auth
|
|
16
|
+
* bag in logs, telemetry attributes, baggage, tool results, message history,
|
|
17
|
+
* or model-visible prompts. Pass only the exact token needed to a trusted
|
|
18
|
+
* Slack API/MCP client.
|
|
19
|
+
*
|
|
20
|
+
* Most fields come from Bolt's enriched `args.context`. They are all optional
|
|
21
|
+
* because availability depends on the auth mode (single-workspace vs OAuth)
|
|
22
|
+
* and on whether the installer granted user scopes.
|
|
23
|
+
*/
|
|
24
|
+
interface SlackAuthContext {
|
|
25
|
+
/** Workspace bot token (`xoxb-...`). */
|
|
26
|
+
botToken?: string;
|
|
27
|
+
/** End-user OAuth token (`xoxp-...`) when user scopes were granted. */
|
|
28
|
+
userToken?: string;
|
|
29
|
+
/** Workspace ID (`T...`). */
|
|
30
|
+
teamId?: string;
|
|
31
|
+
/** Enterprise grid ID (`E...`) when applicable. */
|
|
32
|
+
enterpriseId?: string;
|
|
33
|
+
/** Bot user ID (`U...`) — useful for distinguishing bot self-mentions. */
|
|
34
|
+
botUserId?: string;
|
|
35
|
+
/** Internal Slack bot ID (`B...`). */
|
|
36
|
+
botId?: string;
|
|
37
|
+
/** Slack user ID (`U...`) of the human author of the inbound event. */
|
|
38
|
+
userId?: string;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* Slack assistant lifecycle types — status updates, suggested prompts, thread
|
|
43
|
+
* context, and the channel-neutral `SlackAssistantUtilities` interface that
|
|
44
|
+
* the assistant bridge surfaces ambiently for tools and middleware.
|
|
45
|
+
*/
|
|
46
|
+
/**
|
|
47
|
+
* Slack assistant thread context — the channel of origin metadata Slack tracks
|
|
48
|
+
* while a user navigates the workspace. Surfaces the same fields Bolt's
|
|
49
|
+
* `AssistantThreadContextStore` returns.
|
|
50
|
+
*
|
|
51
|
+
* @see https://docs.slack.dev/reference/events/assistant_thread_context_changed
|
|
52
|
+
*/
|
|
53
|
+
interface SlackAssistantThreadContext {
|
|
54
|
+
channel_id?: string;
|
|
55
|
+
team_id?: string;
|
|
56
|
+
enterprise_id?: string | null;
|
|
57
|
+
}
|
|
58
|
+
/** Display mode passed to `client.chatStream`. */
|
|
59
|
+
type SlackAssistantTaskDisplayMode = "plan" | "timeline";
|
|
60
|
+
/**
|
|
61
|
+
* Slack message authorship fields supported by AI assistant status updates
|
|
62
|
+
* and native chat stream start calls.
|
|
63
|
+
*/
|
|
64
|
+
interface SlackMessageAuthorshipOptions {
|
|
65
|
+
/** Emoji shown as the message/status icon, e.g. `":robot_face:"`. */
|
|
66
|
+
icon_emoji?: string;
|
|
67
|
+
/** Image URL shown as the message/status icon. */
|
|
68
|
+
icon_url?: string;
|
|
69
|
+
/** Display name shown for the message/status. */
|
|
70
|
+
username?: string;
|
|
71
|
+
}
|
|
72
|
+
/** Optional passthrough fields for Slack's native `chat.startStream`. */
|
|
73
|
+
type SlackChatStreamStartArgs = SlackMessageAuthorshipOptions & {
|
|
74
|
+
/**
|
|
75
|
+
* Slack task display mode for streamed tool/task chunks. `timeline` shows
|
|
76
|
+
* individual task cards; `plan` groups task cards together.
|
|
77
|
+
*/
|
|
78
|
+
task_display_mode?: SlackAssistantTaskDisplayMode;
|
|
79
|
+
};
|
|
80
|
+
/** A single suggested prompt chip shown in the assistant pane. */
|
|
81
|
+
interface SlackAssistantSuggestedPrompt {
|
|
82
|
+
title: string;
|
|
83
|
+
message: string;
|
|
84
|
+
}
|
|
85
|
+
/** Suggested prompts payload for `assistant.threads.setSuggestedPrompts`. */
|
|
86
|
+
interface SlackAssistantSuggestedPrompts {
|
|
87
|
+
/** Title shown above the chips. Defaults to Slack's "Try these prompts:". */
|
|
88
|
+
title?: string;
|
|
89
|
+
prompts: SlackAssistantSuggestedPrompt[];
|
|
90
|
+
}
|
|
91
|
+
/** Status payload accepted by Bolt's assistant `setStatus`. */
|
|
92
|
+
interface SlackAssistantStatusUpdate extends SlackMessageAuthorshipOptions {
|
|
93
|
+
status: string;
|
|
94
|
+
loading_messages?: string[];
|
|
95
|
+
}
|
|
96
|
+
/**
|
|
97
|
+
* Assistant pane utilities surfaced ambiently so tools/middleware can call
|
|
98
|
+
* them mid-turn without wiring the raw Bolt args through.
|
|
99
|
+
*
|
|
100
|
+
* Only present when the turn is running through the assistant bridge.
|
|
101
|
+
*/
|
|
102
|
+
interface SlackAssistantUtilities {
|
|
103
|
+
setStatus: (update: SlackAssistantStatusUpdate) => Promise<void>;
|
|
104
|
+
setSuggestedPrompts: (prompts: SlackAssistantSuggestedPrompts) => Promise<void>;
|
|
105
|
+
setTitle: (title: string) => Promise<void>;
|
|
106
|
+
getThreadContext: () => Promise<SlackAssistantThreadContext>;
|
|
107
|
+
saveThreadContext: () => Promise<void>;
|
|
108
|
+
}
|
|
109
|
+
/**
|
|
110
|
+
* Status utility exposed by Bolt for any message/app_mention event with a
|
|
111
|
+
* channel + thread timestamp. It calls Slack's assistant thread status API,
|
|
112
|
+
* but unlike the full Assistant surface it does not imply suggested prompts,
|
|
113
|
+
* thread titles, or origin-channel context.
|
|
114
|
+
*/
|
|
115
|
+
type SlackThreadStatusSetter = (update: SlackAssistantStatusUpdate) => Promise<void>;
|
|
116
|
+
|
|
117
|
+
/**
|
|
118
|
+
* Slack turn-request and turn-preparation contracts shared by Slack transport
|
|
119
|
+
* packages. Direct Slack fills these from Bolt events; M365-backed Slack fills
|
|
120
|
+
* the same shape from Bot Framework activities.
|
|
121
|
+
*/
|
|
122
|
+
|
|
123
|
+
/**
|
|
124
|
+
* Context available while preparing a Slack turn.
|
|
125
|
+
*/
|
|
126
|
+
interface SlackTurnRequestContext {
|
|
127
|
+
/** Parsed Slack activity metadata */
|
|
128
|
+
slackActivity: SlackActivityInfo;
|
|
129
|
+
/** Extracted Slack user identity */
|
|
130
|
+
user: SlackUserIdentity;
|
|
131
|
+
/** Resolved runtime session ID for this conversation */
|
|
132
|
+
sessionId: string;
|
|
133
|
+
/** Plain-text message forwarded to the host application */
|
|
134
|
+
message: string;
|
|
135
|
+
/**
|
|
136
|
+
* Slack auth + identity resolved from the inbound request.
|
|
137
|
+
*
|
|
138
|
+
* Includes the bot token, optional end-user OAuth token, team/enterprise
|
|
139
|
+
* IDs, and bot user ID. Tools and `prepareTurn` callers can use these to
|
|
140
|
+
* call the Slack Web API or attach the user token to MCP servers.
|
|
141
|
+
*/
|
|
142
|
+
auth?: SlackAuthContext;
|
|
143
|
+
/**
|
|
144
|
+
* Assistant thread context resolved by Bolt for assistant-pane turns.
|
|
145
|
+
*
|
|
146
|
+
* Tells the runtime which channel/workspace the user is currently viewing
|
|
147
|
+
* while talking to the assistant — useful for context-aware system prompts
|
|
148
|
+
* and for resolving relative references like "this channel".
|
|
149
|
+
*
|
|
150
|
+
* `undefined` when the turn was not routed through the assistant bridge.
|
|
151
|
+
*/
|
|
152
|
+
threadContext?: SlackAssistantThreadContext;
|
|
153
|
+
/**
|
|
154
|
+
* Slack thread status setter available when Bolt provides `setStatus` for
|
|
155
|
+
* the inbound event. This can be present on classic `app_mention` /
|
|
156
|
+
* `message` turns as well as full Assistant-pane turns.
|
|
157
|
+
*/
|
|
158
|
+
setStatus?: SlackThreadStatusSetter;
|
|
159
|
+
}
|
|
160
|
+
/**
|
|
161
|
+
* Optional turn preparation result for a Slack turn.
|
|
162
|
+
*/
|
|
163
|
+
interface SlackTurnPreparation {
|
|
164
|
+
/** Optional system override for the host application */
|
|
165
|
+
system?: string;
|
|
166
|
+
/** Optional message override for the host application. */
|
|
167
|
+
message?: string;
|
|
168
|
+
/** Optional session override for this turn. */
|
|
169
|
+
sessionId?: string;
|
|
170
|
+
/** Optional custom scope name for the activity */
|
|
171
|
+
scopeName?: string;
|
|
172
|
+
/** Additional scalar attributes merged into the activity scope */
|
|
173
|
+
scopeAttributes?: Record<string, string | number | boolean | null | undefined>;
|
|
174
|
+
/** Arbitrary app-specific per-turn context exposed via AsyncLocalStorage */
|
|
175
|
+
context?: Record<string, unknown>;
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
export type { SlackAssistantStatusUpdate as S, SlackAssistantSuggestedPrompt as a, SlackAssistantSuggestedPrompts as b, SlackAssistantTaskDisplayMode as c, SlackAssistantThreadContext as d, SlackAssistantUtilities as e, SlackAuthContext as f, SlackChatStreamStartArgs as g, SlackMessageAuthorshipOptions as h, SlackThreadStatusSetter as i, SlackTurnPreparation as j, SlackTurnRequestContext as k };
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
import { g as SlackInteractiveRequestContext } from './interactive-CbKYkkc_.js';
|
|
2
|
+
|
|
3
|
+
type SlackInteractiveRequestStatus = "pending" | "resolved";
|
|
4
|
+
type SlackInteractiveApprovalAction = "allow" | "deny" | "remember";
|
|
5
|
+
type SlackInteractiveHumanInputResponse = {
|
|
6
|
+
kind: "text";
|
|
7
|
+
text: string;
|
|
8
|
+
} | {
|
|
9
|
+
kind: "confirm";
|
|
10
|
+
confirmed: boolean;
|
|
11
|
+
text: string;
|
|
12
|
+
} | {
|
|
13
|
+
kind: "choice";
|
|
14
|
+
selected: string[];
|
|
15
|
+
text: string;
|
|
16
|
+
};
|
|
17
|
+
interface SlackInteractiveApprovalRequest {
|
|
18
|
+
id: string;
|
|
19
|
+
tool: string;
|
|
20
|
+
args: unknown;
|
|
21
|
+
description: string;
|
|
22
|
+
risk: string;
|
|
23
|
+
rememberScopes?: string[];
|
|
24
|
+
defaultRememberScope?: string;
|
|
25
|
+
}
|
|
26
|
+
interface SlackInteractiveHumanInputOption {
|
|
27
|
+
label: string;
|
|
28
|
+
value?: string;
|
|
29
|
+
description?: string;
|
|
30
|
+
}
|
|
31
|
+
interface SlackInteractiveHumanInputRequest {
|
|
32
|
+
id: string;
|
|
33
|
+
kind: "text" | "confirm" | "choice";
|
|
34
|
+
title: string;
|
|
35
|
+
question: string;
|
|
36
|
+
options?: SlackInteractiveHumanInputOption[];
|
|
37
|
+
allowMultiple?: boolean;
|
|
38
|
+
placeholder?: string;
|
|
39
|
+
confirmLabel?: string;
|
|
40
|
+
denyLabel?: string;
|
|
41
|
+
}
|
|
42
|
+
type SlackInteractiveStoredRequest = SlackInteractiveApprovalRequest | SlackInteractiveHumanInputRequest;
|
|
43
|
+
type SlackInteractiveResolution = {
|
|
44
|
+
kind: "approval";
|
|
45
|
+
action: SlackInteractiveApprovalAction;
|
|
46
|
+
feedback?: string;
|
|
47
|
+
rememberScope?: string;
|
|
48
|
+
} | {
|
|
49
|
+
kind: "human-input";
|
|
50
|
+
response: SlackInteractiveHumanInputResponse;
|
|
51
|
+
};
|
|
52
|
+
interface SlackInteractiveMessageTarget {
|
|
53
|
+
channel: string;
|
|
54
|
+
ts: string;
|
|
55
|
+
threadTs?: string;
|
|
56
|
+
userId: string;
|
|
57
|
+
teamId?: string;
|
|
58
|
+
}
|
|
59
|
+
interface SlackInteractiveRequestRecord {
|
|
60
|
+
id: string;
|
|
61
|
+
kind: SlackInteractiveResolution["kind"];
|
|
62
|
+
request: SlackInteractiveStoredRequest;
|
|
63
|
+
status: SlackInteractiveRequestStatus;
|
|
64
|
+
createdAt: string;
|
|
65
|
+
updatedAt: string;
|
|
66
|
+
target?: SlackInteractiveMessageTarget;
|
|
67
|
+
resolution?: SlackInteractiveResolution;
|
|
68
|
+
}
|
|
69
|
+
interface SlackInteractiveRequestStore {
|
|
70
|
+
get(requestId: string): Promise<SlackInteractiveRequestRecord | undefined>;
|
|
71
|
+
upsert(record: SlackInteractiveRequestRecord): Promise<SlackInteractiveRequestRecord>;
|
|
72
|
+
attachTarget(requestId: string, target: SlackInteractiveMessageTarget): Promise<SlackInteractiveRequestRecord | undefined>;
|
|
73
|
+
resolve(requestId: string, resolution: SlackInteractiveResolution): Promise<SlackInteractiveRequestRecord | undefined>;
|
|
74
|
+
delete(requestId: string): Promise<void>;
|
|
75
|
+
}
|
|
76
|
+
interface SlackInteractiveActionIds {
|
|
77
|
+
approvalAllow: string;
|
|
78
|
+
approvalDeny: string;
|
|
79
|
+
approvalRemember: string;
|
|
80
|
+
humanConfirm: string;
|
|
81
|
+
humanDeny: string;
|
|
82
|
+
humanOpen: string;
|
|
83
|
+
humanSubmit: string;
|
|
84
|
+
}
|
|
85
|
+
interface SlackInteractiveActor {
|
|
86
|
+
userId: string;
|
|
87
|
+
teamId?: string;
|
|
88
|
+
}
|
|
89
|
+
type SlackInteractiveRequestHandler = (context: SlackInteractiveRequestContext) => boolean | void | Promise<boolean | void>;
|
|
90
|
+
|
|
91
|
+
export type { SlackInteractiveActionIds as S, SlackInteractiveActor as a, SlackInteractiveApprovalAction as b, SlackInteractiveApprovalRequest as c, SlackInteractiveHumanInputOption as d, SlackInteractiveHumanInputRequest as e, SlackInteractiveHumanInputResponse as f, SlackInteractiveMessageTarget as g, SlackInteractiveRequestHandler as h, SlackInteractiveRequestRecord as i, SlackInteractiveRequestStatus as j, SlackInteractiveRequestStore as k, SlackInteractiveResolution as l, SlackInteractiveStoredRequest as m };
|