@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.
- package/LICENSE +201 -0
- package/README.md +80 -0
- package/dist/adapter-Cmd2C90g.d.ts +31 -0
- package/dist/adapter.d.ts +23 -0
- package/dist/adapter.js +13 -0
- package/dist/app-surface.d.ts +71 -0
- package/dist/app-surface.js +12 -0
- package/dist/app.d.ts +54 -0
- package/dist/app.js +14 -0
- package/dist/assistant.d.ts +19 -0
- package/dist/assistant.js +16 -0
- package/dist/bolt.d.ts +8 -0
- package/dist/bolt.js +10 -0
- package/dist/chunk-2SUAW6MV.js +12 -0
- package/dist/chunk-645NNJIM.js +12 -0
- package/dist/chunk-ANIZ5NT4.js +12 -0
- package/dist/chunk-BFUPAJON.js +662 -0
- package/dist/chunk-CYEBGC6G.js +77 -0
- package/dist/chunk-DHPD4XH5.js +827 -0
- package/dist/chunk-FDRQOG7Q.js +471 -0
- package/dist/chunk-GNXWTKQ6.js +48 -0
- package/dist/chunk-HFT2FXJP.js +12 -0
- package/dist/chunk-I2KLQ2HA.js +22 -0
- package/dist/chunk-IWUYIAY5.js +69 -0
- package/dist/chunk-IXY3BXU5.js +689 -0
- package/dist/chunk-JMLB7A2V.js +85 -0
- package/dist/chunk-K2E6A377.js +12 -0
- package/dist/chunk-M64Z6TYL.js +198 -0
- package/dist/chunk-NDVXBI7Z.js +12 -0
- package/dist/chunk-NIPAN4KA.js +76 -0
- package/dist/chunk-PX4RGO3N.js +12 -0
- package/dist/chunk-RFHXERNL.js +27 -0
- package/dist/chunk-VHGV66M7.js +12 -0
- package/dist/chunk-WO4BJMF3.js +82 -0
- package/dist/diagnostics.d.ts +1 -0
- package/dist/diagnostics.js +10 -0
- package/dist/express-assistant.d.ts +102 -0
- package/dist/express-assistant.js +12 -0
- package/dist/express.d.ts +98 -0
- package/dist/express.js +11 -0
- package/dist/feedback.d.ts +1 -0
- package/dist/feedback.js +10 -0
- package/dist/history.d.ts +1 -0
- package/dist/history.js +10 -0
- package/dist/index.d.ts +32 -0
- package/dist/index.js +202 -0
- package/dist/interactive-o_NZb-Xg.d.ts +47 -0
- package/dist/interactive.d.ts +30 -0
- package/dist/interactive.js +25 -0
- package/dist/mcp.d.ts +84 -0
- package/dist/mcp.js +9 -0
- package/dist/options-C7OYeNR-.d.ts +71 -0
- package/dist/options-Uf-qmQKN.d.ts +263 -0
- package/dist/policy.d.ts +1 -0
- package/dist/policy.js +10 -0
- package/dist/setup.d.ts +1 -0
- package/dist/setup.js +10 -0
- package/dist/shared.d.ts +129 -0
- package/dist/shared.js +20 -0
- package/dist/socket.d.ts +137 -0
- package/dist/socket.js +16 -0
- package/dist/targets.d.ts +1 -0
- package/dist/targets.js +10 -0
- package/dist/types-BqRzb_Cd.d.ts +346 -0
- package/dist/types-Crpil4kb.d.ts +136 -0
- package/dist/users.d.ts +1 -0
- package/dist/users.js +10 -0
- package/package.json +169 -0
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
import * as _slack_bolt from '@slack/bolt';
|
|
2
|
+
import { Server } from 'node:http';
|
|
3
|
+
import { AgentTurnSource } from '@cuylabs/agent-core';
|
|
4
|
+
import { Application } from 'express';
|
|
5
|
+
import { c as createSlackChannelAdapter } from './adapter-Cmd2C90g.js';
|
|
6
|
+
import { a as SlackChannelOptions } from './types-BqRzb_Cd.js';
|
|
7
|
+
import { CreateSlackBoltAppOptions, SlackDirectAuthOptions, SlackDirectAuthMode } from '@cuylabs/channel-slack/bolt';
|
|
8
|
+
import '@cuylabs/channel-slack/core';
|
|
9
|
+
import './interactive-o_NZb-Xg.js';
|
|
10
|
+
|
|
11
|
+
interface MountSlackAgentOptions extends Omit<SlackChannelOptions, "agent" | "source">, Omit<CreateSlackBoltAppOptions, "app" | "path" | "botToken" | "signingSecret" | "auth"> {
|
|
12
|
+
/**
|
|
13
|
+
* Slack bot token (`xoxb-...`).
|
|
14
|
+
* @default process.env.SLACK_BOT_TOKEN
|
|
15
|
+
*/
|
|
16
|
+
botToken?: string;
|
|
17
|
+
/**
|
|
18
|
+
* Slack signing secret used to verify incoming webhook requests.
|
|
19
|
+
* @default process.env.SLACK_SIGNING_SECRET
|
|
20
|
+
*/
|
|
21
|
+
signingSecret?: string;
|
|
22
|
+
/**
|
|
23
|
+
* Structured direct-mode auth config.
|
|
24
|
+
*
|
|
25
|
+
* Use this for:
|
|
26
|
+
* - multi-workspace OAuth installs
|
|
27
|
+
* - custom Bolt authorize callbacks
|
|
28
|
+
*
|
|
29
|
+
* When omitted, `mountSlackAgent()` defaults to single-workspace mode
|
|
30
|
+
* using `botToken` / `SLACK_BOT_TOKEN`.
|
|
31
|
+
*/
|
|
32
|
+
auth?: SlackDirectAuthOptions;
|
|
33
|
+
/**
|
|
34
|
+
* Exact Slack Events API callback path handled by Bolt.
|
|
35
|
+
*
|
|
36
|
+
* This becomes the request URL you configure in the Slack app:
|
|
37
|
+
* `https://<your-host>${path}`.
|
|
38
|
+
*
|
|
39
|
+
* @default "/slack/events"
|
|
40
|
+
*/
|
|
41
|
+
path?: string;
|
|
42
|
+
/**
|
|
43
|
+
* Port to listen on.
|
|
44
|
+
* Set to `null` to skip `app.listen()` — caller manages the server.
|
|
45
|
+
* @default process.env.PORT || 3000
|
|
46
|
+
*/
|
|
47
|
+
port?: number | null;
|
|
48
|
+
/**
|
|
49
|
+
* Optional host/interface passed to `app.listen(port, host)`.
|
|
50
|
+
*/
|
|
51
|
+
host?: string;
|
|
52
|
+
/**
|
|
53
|
+
* Pre-existing Express app. If not provided, a new one is created.
|
|
54
|
+
*
|
|
55
|
+
* When provided, the Bolt receiver router is mounted on `path` and no
|
|
56
|
+
* internal `app.listen()` is called (the caller must start the server).
|
|
57
|
+
*/
|
|
58
|
+
app?: Application;
|
|
59
|
+
}
|
|
60
|
+
interface MountSlackAgentResult {
|
|
61
|
+
/** The Express application */
|
|
62
|
+
app: Application;
|
|
63
|
+
/** The Bolt App instance */
|
|
64
|
+
boltApp: _slack_bolt.App;
|
|
65
|
+
/** The Bolt ExpressReceiver */
|
|
66
|
+
receiver: _slack_bolt.ExpressReceiver;
|
|
67
|
+
/** Resolved direct Slack auth mode */
|
|
68
|
+
authMode: SlackDirectAuthMode;
|
|
69
|
+
/** Exact Slack callback path handled by Bolt */
|
|
70
|
+
routePath: string;
|
|
71
|
+
/** The Slack channel adapter */
|
|
72
|
+
channelAdapter: ReturnType<typeof createSlackChannelAdapter>;
|
|
73
|
+
/** The Node HTTP server when `listen()` was started internally */
|
|
74
|
+
server?: Server;
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* Mount an agent-core-compatible turn source as a Slack bot on an Express app.
|
|
78
|
+
*
|
|
79
|
+
* This is the simplest way to deploy an agent-core agent to Slack. It handles:
|
|
80
|
+
* 1. Creating a Bolt `ExpressReceiver` with request verification.
|
|
81
|
+
* 2. Creating a Bolt `App` using one of the supported direct auth modes.
|
|
82
|
+
* 3. Creating the Slack channel adapter and mounting it on the Bolt App.
|
|
83
|
+
* 4. Registering `receiver.router` on the Express app.
|
|
84
|
+
* 5. Optionally starting the server.
|
|
85
|
+
*
|
|
86
|
+
* Single-workspace mode environment variables (if not passed explicitly):
|
|
87
|
+
* - `SLACK_BOT_TOKEN` — Bot OAuth token (`xoxb-...`)
|
|
88
|
+
* - `SLACK_SIGNING_SECRET` — App signing secret for request verification
|
|
89
|
+
*
|
|
90
|
+
* OAuth mode environment variables:
|
|
91
|
+
* - `SLACK_SIGNING_SECRET`
|
|
92
|
+
* - `SLACK_CLIENT_ID`
|
|
93
|
+
* - `SLACK_CLIENT_SECRET`
|
|
94
|
+
* - `SLACK_STATE_SECRET` unless you provide a custom state store
|
|
95
|
+
*/
|
|
96
|
+
declare function mountSlackAgent(source: AgentTurnSource, options?: MountSlackAgentOptions): Promise<MountSlackAgentResult>;
|
|
97
|
+
|
|
98
|
+
export { type MountSlackAgentOptions, type MountSlackAgentResult, mountSlackAgent };
|
package/dist/express.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from '@cuylabs/channel-slack/feedback';
|
package/dist/feedback.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from '@cuylabs/channel-slack/history';
|
package/dist/history.js
ADDED
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
export { ExtractSlackMessageTextOptions, RawSlackActionTokenPayload, RawSlackAppMentionPayload, RawSlackAssistantThreadPayload, RawSlackMessagePayload, SlackActivityInfo, SlackAmbientTurnContext, SlackAssistantStatusUpdate, SlackAssistantSuggestedPrompt, SlackAssistantSuggestedPrompts, SlackAssistantTaskDisplayMode, SlackAssistantThreadContext, SlackAssistantUtilities, SlackAuthContext, SlackChannelType, SlackChatStreamStartArgs, SlackMessageAuthorshipOptions, SlackMessageFormatter, SlackMessageFormattingOptions, SlackMessageTextPayload, SlackThreadStatusSetter, SlackTurnPreparation, SlackTurnRequestContext, SlackUserIdentity, currentSlackTurnContext, extractSlackActionToken, extractSlackAttachmentsText, extractSlackAuthContext, extractSlackBlocksText, extractSlackMessageText, extractSlackUserIdentity, formatSlackAttributedFollowUp, isProcessableMessage, markdownToSlackMrkdwn, parseSlackMentionActivity, parseSlackMessageActivity, resolveSlackChannelType, resolveSlackMessageFormatter, resolveThreadAwareSlackSessionId, runWithSlackTurnContext, stripLeadingMentions } from '@cuylabs/channel-slack/core';
|
|
2
|
+
export { S as SlackApprovalRequest, a as SlackEventInteractiveRequestHandler, b as SlackHumanInputRequest, c as SlackInteractiveMessage, d as SlackInteractiveMessageRef, e as SlackInteractiveRequest, f as SlackInteractiveRequestBaseContext, g as SlackInteractiveRequestContext, h as SlackInteractiveRequestHandler, i as SlackInteractiveRequestKind, j as SlackInteractiveResponder } from './interactive-o_NZb-Xg.js';
|
|
3
|
+
export { DEFAULT_SLACK_CONTEXT_FRAGMENT_KEY, SlackChatStream, SlackContextFragmentMiddlewareOptions, SlackContextFragmentPayload, SlackContextFragmentResolver, SlackContextFragmentResolverContext, SlackResponseSink, SlackStreamChunk, SlackStreamTaskStatus, UnsupportedSlackInteractiveRequestError, bridgeAgentEventsToSlack, createSlackContextFragmentMiddleware } from './shared.js';
|
|
4
|
+
export { S as SlackEventBridgeOptions, r as resolveSlackEventBridgeOptions } from './options-C7OYeNR-.js';
|
|
5
|
+
export * from '@cuylabs/channel-slack/bolt';
|
|
6
|
+
export { c as createSlackChannelAdapter } from './adapter-Cmd2C90g.js';
|
|
7
|
+
export { S as SlackChannelAdapter, a as SlackChannelOptions, b as SlackSessionStrategy, c as SlackStreamingMode, d as SlackToolStartEvent } from './types-BqRzb_Cd.js';
|
|
8
|
+
export { SlackSessionMap, createSlackSessionMap } from './adapter.js';
|
|
9
|
+
export { createSlackAssistantBridge } from './assistant.js';
|
|
10
|
+
export { A as AssistantLifecycleArgs, a as AssistantThreadStartedArgs, C as CreateSlackAssistantBridgeOptions, M as MaybePromise, S as SlackAssistantBridge, b as SlackAssistantFeedbackConfig, c as SlackAssistantSessionStrategy, d as SlackAssistantStatusContext, e as SlackAssistantThreadContextStoreLike, f as SlackAssistantThreadStartedContext, g as SlackAssistantTurnPreparation, h as SlackAssistantUserMessageContext, r as resolveAssistantSessionId } from './options-Uf-qmQKN.js';
|
|
11
|
+
export { ParsedAssistantUserMessage, createSlackAssistantThreadContextStore, parseSlackMessageActivityFromMessageEvent } from '@cuylabs/channel-slack/assistant';
|
|
12
|
+
export * from '@cuylabs/channel-slack/history';
|
|
13
|
+
export { S as SlackInteractiveActionIds, a as SlackInteractiveActor, b as SlackInteractiveApprovalRequest, c as SlackInteractiveController, d as SlackInteractiveControllerOptions, e as SlackInteractiveHumanInputRequest, f as SlackInteractiveMessageTarget, g as SlackInteractivePendingWaiter, h as SlackInteractivePostedMessage, i as SlackInteractiveRequestRecord, j as SlackInteractiveRequestStatus, k as SlackInteractiveRequestStore, l as SlackInteractiveRequestWaitOptions, m as SlackInteractiveResolution, n as SlackInteractiveStoredRequest } from './types-Crpil4kb.js';
|
|
14
|
+
export { buildApprovalRequestMessage, buildHumanInputModal, buildHumanInputRequestMessage, buildResolvedMessage, cloneRecord, createInMemorySlackInteractiveRequestStore, createSlackInteractiveController, decodeActionValue, encodeActionValue, nowIso } from './interactive.js';
|
|
15
|
+
export * from '@cuylabs/channel-slack/policy';
|
|
16
|
+
export * from '@cuylabs/channel-slack/users';
|
|
17
|
+
export * from '@cuylabs/channel-slack/diagnostics';
|
|
18
|
+
export * from '@cuylabs/channel-slack/setup';
|
|
19
|
+
export * from '@cuylabs/channel-slack/targets';
|
|
20
|
+
export { MountSlackAgentOptions, MountSlackAgentResult, mountSlackAgent } from './express.js';
|
|
21
|
+
export { MountSlackAssistantAgentOptions, MountSlackAssistantAgentResult, mountSlackAssistantAgent } from './express-assistant.js';
|
|
22
|
+
export { MountSlackAgentAppSocketOptions, MountSlackAgentAppSocketResult, MountSlackAssistantAgentSocketOptions, MountSlackAssistantAgentSocketResult, mountSlackAgentAppSocket, mountSlackAssistantAgentSocket } from './socket.js';
|
|
23
|
+
export { MountSlackAgentAppOptions, MountSlackAgentAppResult, mountSlackAgentApp } from './app.js';
|
|
24
|
+
export { CreateSlackMcpServerConfigOptions, SLACK_MCP_URL, createSlackMcpServerConfig } from './mcp.js';
|
|
25
|
+
export { MountSlackAgentAppTurnRequestContext } from './app-surface.js';
|
|
26
|
+
import '@cuylabs/agent-core';
|
|
27
|
+
import '@slack/bolt';
|
|
28
|
+
import '@slack/web-api';
|
|
29
|
+
import '@cuylabs/channel-slack/feedback';
|
|
30
|
+
import 'node:http';
|
|
31
|
+
import 'express';
|
|
32
|
+
import '@cuylabs/agent-core/mcp';
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
import {
|
|
2
|
+
mountSlackAgentAppSocket,
|
|
3
|
+
mountSlackAssistantAgentSocket
|
|
4
|
+
} from "./chunk-IWUYIAY5.js";
|
|
5
|
+
import {
|
|
6
|
+
targets_exports
|
|
7
|
+
} from "./chunk-K2E6A377.js";
|
|
8
|
+
import {
|
|
9
|
+
users_exports
|
|
10
|
+
} from "./chunk-HFT2FXJP.js";
|
|
11
|
+
import {
|
|
12
|
+
history_exports
|
|
13
|
+
} from "./chunk-PX4RGO3N.js";
|
|
14
|
+
import {
|
|
15
|
+
buildApprovalRequestMessage,
|
|
16
|
+
buildHumanInputModal,
|
|
17
|
+
buildHumanInputRequestMessage,
|
|
18
|
+
buildResolvedMessage,
|
|
19
|
+
cloneRecord,
|
|
20
|
+
createInMemorySlackInteractiveRequestStore,
|
|
21
|
+
createSlackInteractiveController,
|
|
22
|
+
decodeActionValue,
|
|
23
|
+
encodeActionValue,
|
|
24
|
+
nowIso
|
|
25
|
+
} from "./chunk-IXY3BXU5.js";
|
|
26
|
+
import {
|
|
27
|
+
SLACK_MCP_URL,
|
|
28
|
+
createSlackMcpServerConfig
|
|
29
|
+
} from "./chunk-RFHXERNL.js";
|
|
30
|
+
import {
|
|
31
|
+
policy_exports
|
|
32
|
+
} from "./chunk-2SUAW6MV.js";
|
|
33
|
+
import {
|
|
34
|
+
setup_exports
|
|
35
|
+
} from "./chunk-645NNJIM.js";
|
|
36
|
+
import {
|
|
37
|
+
DEFAULT_SLACK_CONTEXT_FRAGMENT_KEY,
|
|
38
|
+
createSlackContextFragmentMiddleware
|
|
39
|
+
} from "./chunk-NIPAN4KA.js";
|
|
40
|
+
import {
|
|
41
|
+
mountSlackAgentApp
|
|
42
|
+
} from "./chunk-CYEBGC6G.js";
|
|
43
|
+
import "./chunk-M64Z6TYL.js";
|
|
44
|
+
import {
|
|
45
|
+
diagnostics_exports
|
|
46
|
+
} from "./chunk-NDVXBI7Z.js";
|
|
47
|
+
import {
|
|
48
|
+
mountSlackAssistantAgent
|
|
49
|
+
} from "./chunk-JMLB7A2V.js";
|
|
50
|
+
import {
|
|
51
|
+
createSlackAssistantBridge,
|
|
52
|
+
createSlackAssistantThreadContextStore,
|
|
53
|
+
parseSlackMessageActivityFromMessageEvent,
|
|
54
|
+
resolveAssistantSessionId
|
|
55
|
+
} from "./chunk-BFUPAJON.js";
|
|
56
|
+
import "./chunk-VHGV66M7.js";
|
|
57
|
+
import {
|
|
58
|
+
mountSlackAgent
|
|
59
|
+
} from "./chunk-WO4BJMF3.js";
|
|
60
|
+
import {
|
|
61
|
+
createSlackChannelAdapter,
|
|
62
|
+
createSlackSessionMap,
|
|
63
|
+
resolveThreadAwareSlackSessionId
|
|
64
|
+
} from "./chunk-FDRQOG7Q.js";
|
|
65
|
+
import {
|
|
66
|
+
extractSlackActionToken,
|
|
67
|
+
extractSlackAttachmentsText,
|
|
68
|
+
extractSlackAuthContext,
|
|
69
|
+
extractSlackBlocksText,
|
|
70
|
+
extractSlackMessageText,
|
|
71
|
+
extractSlackUserIdentity,
|
|
72
|
+
isProcessableMessage,
|
|
73
|
+
markdownToSlackMrkdwn,
|
|
74
|
+
parseSlackMentionActivity,
|
|
75
|
+
parseSlackMessageActivity,
|
|
76
|
+
resolveSlackChannelType,
|
|
77
|
+
resolveSlackMessageFormatter,
|
|
78
|
+
stripLeadingMentions
|
|
79
|
+
} from "./chunk-GNXWTKQ6.js";
|
|
80
|
+
import {
|
|
81
|
+
UnsupportedSlackInteractiveRequestError,
|
|
82
|
+
bridgeAgentEventsToSlack,
|
|
83
|
+
currentSlackTurnContext,
|
|
84
|
+
resolveSlackEventBridgeOptions,
|
|
85
|
+
runWithSlackTurnContext
|
|
86
|
+
} from "./chunk-DHPD4XH5.js";
|
|
87
|
+
import {
|
|
88
|
+
bolt_exports
|
|
89
|
+
} from "./chunk-ANIZ5NT4.js";
|
|
90
|
+
import {
|
|
91
|
+
__export,
|
|
92
|
+
__reExport
|
|
93
|
+
} from "./chunk-I2KLQ2HA.js";
|
|
94
|
+
|
|
95
|
+
// src/index.ts
|
|
96
|
+
var index_exports = {};
|
|
97
|
+
__export(index_exports, {
|
|
98
|
+
DEFAULT_SLACK_CONTEXT_FRAGMENT_KEY: () => DEFAULT_SLACK_CONTEXT_FRAGMENT_KEY,
|
|
99
|
+
SLACK_MCP_URL: () => SLACK_MCP_URL,
|
|
100
|
+
UnsupportedSlackInteractiveRequestError: () => UnsupportedSlackInteractiveRequestError,
|
|
101
|
+
bridgeAgentEventsToSlack: () => bridgeAgentEventsToSlack,
|
|
102
|
+
buildApprovalRequestMessage: () => buildApprovalRequestMessage,
|
|
103
|
+
buildHumanInputModal: () => buildHumanInputModal,
|
|
104
|
+
buildHumanInputRequestMessage: () => buildHumanInputRequestMessage,
|
|
105
|
+
buildResolvedMessage: () => buildResolvedMessage,
|
|
106
|
+
cloneRecord: () => cloneRecord,
|
|
107
|
+
createInMemorySlackInteractiveRequestStore: () => createInMemorySlackInteractiveRequestStore,
|
|
108
|
+
createSlackAssistantBridge: () => createSlackAssistantBridge,
|
|
109
|
+
createSlackAssistantThreadContextStore: () => createSlackAssistantThreadContextStore,
|
|
110
|
+
createSlackChannelAdapter: () => createSlackChannelAdapter,
|
|
111
|
+
createSlackContextFragmentMiddleware: () => createSlackContextFragmentMiddleware,
|
|
112
|
+
createSlackInteractiveController: () => createSlackInteractiveController,
|
|
113
|
+
createSlackMcpServerConfig: () => createSlackMcpServerConfig,
|
|
114
|
+
createSlackSessionMap: () => createSlackSessionMap,
|
|
115
|
+
currentSlackTurnContext: () => currentSlackTurnContext,
|
|
116
|
+
decodeActionValue: () => decodeActionValue,
|
|
117
|
+
encodeActionValue: () => encodeActionValue,
|
|
118
|
+
extractSlackActionToken: () => extractSlackActionToken,
|
|
119
|
+
extractSlackAttachmentsText: () => extractSlackAttachmentsText,
|
|
120
|
+
extractSlackAuthContext: () => extractSlackAuthContext,
|
|
121
|
+
extractSlackBlocksText: () => extractSlackBlocksText,
|
|
122
|
+
extractSlackMessageText: () => extractSlackMessageText,
|
|
123
|
+
extractSlackUserIdentity: () => extractSlackUserIdentity,
|
|
124
|
+
formatSlackAttributedFollowUp: () => formatSlackAttributedFollowUp,
|
|
125
|
+
isProcessableMessage: () => isProcessableMessage,
|
|
126
|
+
markdownToSlackMrkdwn: () => markdownToSlackMrkdwn,
|
|
127
|
+
mountSlackAgent: () => mountSlackAgent,
|
|
128
|
+
mountSlackAgentApp: () => mountSlackAgentApp,
|
|
129
|
+
mountSlackAgentAppSocket: () => mountSlackAgentAppSocket,
|
|
130
|
+
mountSlackAssistantAgent: () => mountSlackAssistantAgent,
|
|
131
|
+
mountSlackAssistantAgentSocket: () => mountSlackAssistantAgentSocket,
|
|
132
|
+
nowIso: () => nowIso,
|
|
133
|
+
parseSlackMentionActivity: () => parseSlackMentionActivity,
|
|
134
|
+
parseSlackMessageActivity: () => parseSlackMessageActivity,
|
|
135
|
+
parseSlackMessageActivityFromMessageEvent: () => parseSlackMessageActivityFromMessageEvent,
|
|
136
|
+
resolveAssistantSessionId: () => resolveAssistantSessionId,
|
|
137
|
+
resolveSlackChannelType: () => resolveSlackChannelType,
|
|
138
|
+
resolveSlackEventBridgeOptions: () => resolveSlackEventBridgeOptions,
|
|
139
|
+
resolveSlackMessageFormatter: () => resolveSlackMessageFormatter,
|
|
140
|
+
resolveThreadAwareSlackSessionId: () => resolveThreadAwareSlackSessionId,
|
|
141
|
+
runWithSlackTurnContext: () => runWithSlackTurnContext,
|
|
142
|
+
stripLeadingMentions: () => stripLeadingMentions
|
|
143
|
+
});
|
|
144
|
+
|
|
145
|
+
// src/shared/follow-up.ts
|
|
146
|
+
import { formatSlackAttributedFollowUp } from "@cuylabs/channel-slack/core";
|
|
147
|
+
|
|
148
|
+
// src/index.ts
|
|
149
|
+
__reExport(index_exports, bolt_exports);
|
|
150
|
+
__reExport(index_exports, history_exports);
|
|
151
|
+
__reExport(index_exports, policy_exports);
|
|
152
|
+
__reExport(index_exports, users_exports);
|
|
153
|
+
__reExport(index_exports, diagnostics_exports);
|
|
154
|
+
__reExport(index_exports, setup_exports);
|
|
155
|
+
__reExport(index_exports, targets_exports);
|
|
156
|
+
export {
|
|
157
|
+
DEFAULT_SLACK_CONTEXT_FRAGMENT_KEY,
|
|
158
|
+
SLACK_MCP_URL,
|
|
159
|
+
UnsupportedSlackInteractiveRequestError,
|
|
160
|
+
bridgeAgentEventsToSlack,
|
|
161
|
+
buildApprovalRequestMessage,
|
|
162
|
+
buildHumanInputModal,
|
|
163
|
+
buildHumanInputRequestMessage,
|
|
164
|
+
buildResolvedMessage,
|
|
165
|
+
cloneRecord,
|
|
166
|
+
createInMemorySlackInteractiveRequestStore,
|
|
167
|
+
createSlackAssistantBridge,
|
|
168
|
+
createSlackAssistantThreadContextStore,
|
|
169
|
+
createSlackChannelAdapter,
|
|
170
|
+
createSlackContextFragmentMiddleware,
|
|
171
|
+
createSlackInteractiveController,
|
|
172
|
+
createSlackMcpServerConfig,
|
|
173
|
+
createSlackSessionMap,
|
|
174
|
+
currentSlackTurnContext,
|
|
175
|
+
decodeActionValue,
|
|
176
|
+
encodeActionValue,
|
|
177
|
+
extractSlackActionToken,
|
|
178
|
+
extractSlackAttachmentsText,
|
|
179
|
+
extractSlackAuthContext,
|
|
180
|
+
extractSlackBlocksText,
|
|
181
|
+
extractSlackMessageText,
|
|
182
|
+
extractSlackUserIdentity,
|
|
183
|
+
formatSlackAttributedFollowUp,
|
|
184
|
+
isProcessableMessage,
|
|
185
|
+
markdownToSlackMrkdwn,
|
|
186
|
+
mountSlackAgent,
|
|
187
|
+
mountSlackAgentApp,
|
|
188
|
+
mountSlackAgentAppSocket,
|
|
189
|
+
mountSlackAssistantAgent,
|
|
190
|
+
mountSlackAssistantAgentSocket,
|
|
191
|
+
nowIso,
|
|
192
|
+
parseSlackMentionActivity,
|
|
193
|
+
parseSlackMessageActivity,
|
|
194
|
+
parseSlackMessageActivityFromMessageEvent,
|
|
195
|
+
resolveAssistantSessionId,
|
|
196
|
+
resolveSlackChannelType,
|
|
197
|
+
resolveSlackEventBridgeOptions,
|
|
198
|
+
resolveSlackMessageFormatter,
|
|
199
|
+
resolveThreadAwareSlackSessionId,
|
|
200
|
+
runWithSlackTurnContext,
|
|
201
|
+
stripLeadingMentions
|
|
202
|
+
};
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { AgentEvent } from '@cuylabs/agent-core';
|
|
2
|
+
import { SlackActivityInfo, SlackUserIdentity } from '@cuylabs/channel-slack/core';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Transport-neutral interactive request contracts.
|
|
6
|
+
*
|
|
7
|
+
* These types let the shared AgentEvent bridge delegate approval and
|
|
8
|
+
* human-input requests to a Slack-specific renderer without importing Bolt or
|
|
9
|
+
* Web API types into `shared/`.
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
type SlackInteractiveRequestKind = "approval" | "human-input";
|
|
13
|
+
type SlackApprovalRequest = Extract<AgentEvent, {
|
|
14
|
+
type: "approval-request";
|
|
15
|
+
}>["request"];
|
|
16
|
+
type SlackHumanInputRequest = Extract<AgentEvent, {
|
|
17
|
+
type: "human-input-request";
|
|
18
|
+
}>["request"];
|
|
19
|
+
type SlackInteractiveRequest = SlackApprovalRequest | SlackHumanInputRequest;
|
|
20
|
+
interface SlackInteractiveMessageRef {
|
|
21
|
+
channel: string;
|
|
22
|
+
ts: string;
|
|
23
|
+
}
|
|
24
|
+
interface SlackInteractiveMessage {
|
|
25
|
+
text: string;
|
|
26
|
+
blocks?: unknown[];
|
|
27
|
+
}
|
|
28
|
+
interface SlackInteractiveResponder {
|
|
29
|
+
postMessage(message: SlackInteractiveMessage): Promise<SlackInteractiveMessageRef>;
|
|
30
|
+
updateMessage(ref: SlackInteractiveMessageRef, message: SlackInteractiveMessage): Promise<void>;
|
|
31
|
+
}
|
|
32
|
+
interface SlackInteractiveRequestBaseContext {
|
|
33
|
+
kind: SlackInteractiveRequestKind;
|
|
34
|
+
request: SlackInteractiveRequest;
|
|
35
|
+
fallbackText: string;
|
|
36
|
+
}
|
|
37
|
+
interface SlackInteractiveRequestContext extends SlackInteractiveRequestBaseContext {
|
|
38
|
+
slackActivity: SlackActivityInfo;
|
|
39
|
+
user: SlackUserIdentity;
|
|
40
|
+
sessionId: string;
|
|
41
|
+
message: string;
|
|
42
|
+
responder: SlackInteractiveResponder;
|
|
43
|
+
}
|
|
44
|
+
type SlackInteractiveRequestHandler = (context: SlackInteractiveRequestContext) => boolean | void | Promise<boolean | void>;
|
|
45
|
+
type SlackEventInteractiveRequestHandler = (context: SlackInteractiveRequestBaseContext) => boolean | void | Promise<boolean | void>;
|
|
46
|
+
|
|
47
|
+
export type { SlackApprovalRequest as S, SlackEventInteractiveRequestHandler as a, SlackHumanInputRequest as b, SlackInteractiveMessage as c, SlackInteractiveMessageRef as d, SlackInteractiveRequest as e, SlackInteractiveRequestBaseContext as f, SlackInteractiveRequestContext as g, SlackInteractiveRequestHandler as h, SlackInteractiveRequestKind as i, SlackInteractiveResponder as j };
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { i as SlackInteractiveRequestRecord, k as SlackInteractiveRequestStore, b as SlackInteractiveApprovalRequest, S as SlackInteractiveActionIds, e as SlackInteractiveHumanInputRequest, m as SlackInteractiveResolution, d as SlackInteractiveControllerOptions, c as SlackInteractiveController } from './types-Crpil4kb.js';
|
|
2
|
+
export { a as SlackInteractiveActor, f as SlackInteractiveMessageTarget, g as SlackInteractivePendingWaiter, h as SlackInteractivePostedMessage, j as SlackInteractiveRequestStatus, l as SlackInteractiveRequestWaitOptions, n as SlackInteractiveStoredRequest } from './types-Crpil4kb.js';
|
|
3
|
+
import '@cuylabs/agent-core';
|
|
4
|
+
import '@slack/bolt';
|
|
5
|
+
import './interactive-o_NZb-Xg.js';
|
|
6
|
+
import '@cuylabs/channel-slack/core';
|
|
7
|
+
|
|
8
|
+
declare function createInMemorySlackInteractiveRequestStore(): SlackInteractiveRequestStore;
|
|
9
|
+
declare function nowIso(): string;
|
|
10
|
+
declare function cloneRecord(record: SlackInteractiveRequestRecord): SlackInteractiveRequestRecord;
|
|
11
|
+
|
|
12
|
+
declare function buildApprovalRequestMessage(request: SlackInteractiveApprovalRequest, actionIds: SlackInteractiveActionIds): {
|
|
13
|
+
text: string;
|
|
14
|
+
blocks: unknown[];
|
|
15
|
+
};
|
|
16
|
+
declare function buildHumanInputRequestMessage(request: SlackInteractiveHumanInputRequest, actionIds: SlackInteractiveActionIds): {
|
|
17
|
+
text: string;
|
|
18
|
+
blocks: unknown[];
|
|
19
|
+
};
|
|
20
|
+
declare function buildResolvedMessage(label: string, resolution: SlackInteractiveResolution): {
|
|
21
|
+
text: string;
|
|
22
|
+
blocks: unknown[];
|
|
23
|
+
};
|
|
24
|
+
declare function buildHumanInputModal(request: SlackInteractiveHumanInputRequest, actionIds: SlackInteractiveActionIds): Record<string, unknown>;
|
|
25
|
+
declare function encodeActionValue(payload: Record<string, unknown>): string;
|
|
26
|
+
declare function decodeActionValue(value: unknown): Record<string, unknown>;
|
|
27
|
+
|
|
28
|
+
declare function createSlackInteractiveController(options?: SlackInteractiveControllerOptions): SlackInteractiveController;
|
|
29
|
+
|
|
30
|
+
export { SlackInteractiveActionIds, SlackInteractiveApprovalRequest, SlackInteractiveController, SlackInteractiveControllerOptions, SlackInteractiveHumanInputRequest, SlackInteractiveRequestRecord, SlackInteractiveRequestStore, SlackInteractiveResolution, buildApprovalRequestMessage, buildHumanInputModal, buildHumanInputRequestMessage, buildResolvedMessage, cloneRecord, createInMemorySlackInteractiveRequestStore, createSlackInteractiveController, decodeActionValue, encodeActionValue, nowIso };
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import {
|
|
2
|
+
buildApprovalRequestMessage,
|
|
3
|
+
buildHumanInputModal,
|
|
4
|
+
buildHumanInputRequestMessage,
|
|
5
|
+
buildResolvedMessage,
|
|
6
|
+
cloneRecord,
|
|
7
|
+
createInMemorySlackInteractiveRequestStore,
|
|
8
|
+
createSlackInteractiveController,
|
|
9
|
+
decodeActionValue,
|
|
10
|
+
encodeActionValue,
|
|
11
|
+
nowIso
|
|
12
|
+
} from "./chunk-IXY3BXU5.js";
|
|
13
|
+
import "./chunk-I2KLQ2HA.js";
|
|
14
|
+
export {
|
|
15
|
+
buildApprovalRequestMessage,
|
|
16
|
+
buildHumanInputModal,
|
|
17
|
+
buildHumanInputRequestMessage,
|
|
18
|
+
buildResolvedMessage,
|
|
19
|
+
cloneRecord,
|
|
20
|
+
createInMemorySlackInteractiveRequestStore,
|
|
21
|
+
createSlackInteractiveController,
|
|
22
|
+
decodeActionValue,
|
|
23
|
+
encodeActionValue,
|
|
24
|
+
nowIso
|
|
25
|
+
};
|
package/dist/mcp.d.ts
ADDED
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import { MCPServerConfig } from '@cuylabs/agent-core/mcp';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Slack MCP integration helpers.
|
|
5
|
+
*
|
|
6
|
+
* Slack hosts an official Model Context Protocol server at
|
|
7
|
+
* `https://mcp.slack.com/mcp` that exposes Slack tools (search, read, write,
|
|
8
|
+
* canvases) authenticated with an end-user OAuth token. This module produces a
|
|
9
|
+
* `MCPServerConfig` that plugs straight into agent-core's MCP manager
|
|
10
|
+
* without forcing every caller to remember the URL or token-header convention.
|
|
11
|
+
*
|
|
12
|
+
* @example Wire per-turn from the assistant bridge
|
|
13
|
+
* ```ts
|
|
14
|
+
* import { createMCPManager } from "@cuylabs/agent-core/mcp";
|
|
15
|
+
* import {
|
|
16
|
+
* createSlackMcpServerConfig,
|
|
17
|
+
* mountSlackAssistantAgent,
|
|
18
|
+
* } from "@cuylabs/channel-slack-agent-core";
|
|
19
|
+
*
|
|
20
|
+
* await mountSlackAssistantAgent({
|
|
21
|
+
* source: agent,
|
|
22
|
+
* prepareTurn: async ({ auth }) => {
|
|
23
|
+
* if (!auth.userToken) return {};
|
|
24
|
+
* // Hand the user token to your agent runtime via ambient context, env,
|
|
25
|
+
* // or a turn-scoped MCP manager you control. agent-core does not yet
|
|
26
|
+
* // accept per-turn MCP servers on `chat()`, so the typical pattern is
|
|
27
|
+
* // to run an MCP-aware Agent that reads `currentSlackTurnContext()`
|
|
28
|
+
* // inside its setup.
|
|
29
|
+
* return { context: { slackMcpServer: createSlackMcpServerConfig({ userToken: auth.userToken }) } };
|
|
30
|
+
* },
|
|
31
|
+
* });
|
|
32
|
+
* ```
|
|
33
|
+
*
|
|
34
|
+
* @example Static agent-level wiring (single-workspace bot token mode)
|
|
35
|
+
* ```ts
|
|
36
|
+
* const manager = createMCPManager({
|
|
37
|
+
* slack: createSlackMcpServerConfig({ userToken: process.env.SLACK_USER_TOKEN! }),
|
|
38
|
+
* });
|
|
39
|
+
* await manager.connect();
|
|
40
|
+
* ```
|
|
41
|
+
*/
|
|
42
|
+
|
|
43
|
+
/** Slack's hosted MCP endpoint (Streamable HTTP transport). */
|
|
44
|
+
declare const SLACK_MCP_URL = "https://mcp.slack.com/mcp";
|
|
45
|
+
interface CreateSlackMcpServerConfigOptions {
|
|
46
|
+
/**
|
|
47
|
+
* Slack user OAuth token (`xoxp-...`).
|
|
48
|
+
*
|
|
49
|
+
* The Slack MCP server requires a user token because most Slack tools
|
|
50
|
+
* (search, read history, write messages) act as the installing user.
|
|
51
|
+
*/
|
|
52
|
+
userToken: string;
|
|
53
|
+
/**
|
|
54
|
+
* Override the MCP server URL. Defaults to `SLACK_MCP_URL`. Useful for
|
|
55
|
+
* regional endpoints or self-hosted Slack MCP deployments.
|
|
56
|
+
*/
|
|
57
|
+
url?: string;
|
|
58
|
+
/**
|
|
59
|
+
* Additional headers to merge alongside `Authorization`. The bearer token
|
|
60
|
+
* is always set from `userToken` and cannot be overridden here.
|
|
61
|
+
*/
|
|
62
|
+
headers?: Record<string, string>;
|
|
63
|
+
/**
|
|
64
|
+
* Connection timeout in milliseconds, forwarded to the MCP manager.
|
|
65
|
+
*/
|
|
66
|
+
timeout?: number;
|
|
67
|
+
/**
|
|
68
|
+
* Whether the server is enabled. Defaults to `true`. Set to `false` to
|
|
69
|
+
* register the config without connecting (useful when the user token is
|
|
70
|
+
* conditionally available).
|
|
71
|
+
*/
|
|
72
|
+
enabled?: boolean;
|
|
73
|
+
/** Human-readable server name shown by MCP status/reporting surfaces. */
|
|
74
|
+
name?: string;
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* Build an MCP server config for Slack's hosted MCP server.
|
|
78
|
+
*
|
|
79
|
+
* The returned value is consumable by `createMCPManager(...)` from
|
|
80
|
+
* `@cuylabs/agent-core/mcp`.
|
|
81
|
+
*/
|
|
82
|
+
declare function createSlackMcpServerConfig(options: CreateSlackMcpServerConfigOptions): MCPServerConfig;
|
|
83
|
+
|
|
84
|
+
export { type CreateSlackMcpServerConfigOptions, SLACK_MCP_URL, createSlackMcpServerConfig };
|
package/dist/mcp.js
ADDED
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import { AgentEvent, ApprovalEvent } from '@cuylabs/agent-core';
|
|
2
|
+
import { a as SlackEventInteractiveRequestHandler } from './interactive-o_NZb-Xg.js';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Event-bridge configuration. The bridge is mode-aware (progressive,
|
|
6
|
+
* accumulate, chat-stream) and these options control formatting, status
|
|
7
|
+
* propagation, interactive-request handling, and chat-stream finalization.
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
type HumanInputEvent = Extract<AgentEvent, {
|
|
11
|
+
type: "human-input-request";
|
|
12
|
+
}>["request"];
|
|
13
|
+
type ToolStartEvent = Extract<AgentEvent, {
|
|
14
|
+
type: "tool-start";
|
|
15
|
+
}>;
|
|
16
|
+
interface SlackEventBridgeOptions {
|
|
17
|
+
showReasoning: boolean;
|
|
18
|
+
/** Render root-agent tool rows/status updates. */
|
|
19
|
+
showToolUsage: boolean;
|
|
20
|
+
/** Render subagent child tool rows in the parent Slack task timeline. */
|
|
21
|
+
showSubagentToolUsage: boolean;
|
|
22
|
+
/** Include full subagent completion output in the subagent task row. */
|
|
23
|
+
showSubagentResultInTask: boolean;
|
|
24
|
+
formatToolTitle?: (toolName: string) => string;
|
|
25
|
+
formatToolUpdate: (toolName: string) => string;
|
|
26
|
+
formatToolDetails?: (event: ToolStartEvent) => string | undefined;
|
|
27
|
+
formatToolError: (toolName: string, error: string) => string;
|
|
28
|
+
formatReasoningUpdate: () => string;
|
|
29
|
+
formatMessageText: (text: string) => string;
|
|
30
|
+
streamingMode: "progressive" | "accumulate" | "chat-stream";
|
|
31
|
+
progressiveUpdateThreshold: number;
|
|
32
|
+
progressiveUpdateIntervalMs: number;
|
|
33
|
+
chatStreamBufferSize: number;
|
|
34
|
+
/**
|
|
35
|
+
* Maximum number of Slack task-update chunks the bridge will append to a
|
|
36
|
+
* single chat stream. Task rows are a bounded UI projection, not a durable
|
|
37
|
+
* event log.
|
|
38
|
+
*/
|
|
39
|
+
maxTaskUpdates: number;
|
|
40
|
+
/**
|
|
41
|
+
* Maximum cumulative characters from task titles/details/output that the
|
|
42
|
+
* bridge will append to one chat stream.
|
|
43
|
+
*/
|
|
44
|
+
maxTaskUpdateTextChars: number;
|
|
45
|
+
/**
|
|
46
|
+
* Maximum characters for a single task details/output field.
|
|
47
|
+
*/
|
|
48
|
+
maxTaskUpdateFieldChars: number;
|
|
49
|
+
interactiveMode: "message-and-error" | "ignore";
|
|
50
|
+
handleInteractiveRequest?: SlackEventInteractiveRequestHandler;
|
|
51
|
+
formatApprovalRequired: (request: ApprovalEvent) => string;
|
|
52
|
+
formatHumanInputRequired: (request: HumanInputEvent) => string;
|
|
53
|
+
/**
|
|
54
|
+
* Optional hook called whenever the bridge's status label changes — used by
|
|
55
|
+
* the assistant bridge to update the assistant pane's status line via
|
|
56
|
+
* `assistant.threads.setStatus`. Errors are swallowed by the caller.
|
|
57
|
+
*/
|
|
58
|
+
onStatusChange?: (label: string, event: AgentEvent | undefined) => void | Promise<void>;
|
|
59
|
+
/**
|
|
60
|
+
* Optional final-args passthrough for `chatStream.stop(...)`. When the
|
|
61
|
+
* bridge stops the chat stream on `complete`, these args (e.g. final
|
|
62
|
+
* `blocks` for a feedback widget) are merged into the `stop` call. The
|
|
63
|
+
* existing `markdown_text` final-text fallback always wins on text fields.
|
|
64
|
+
*/
|
|
65
|
+
chatStreamFinalArgs?: {
|
|
66
|
+
blocks?: unknown[];
|
|
67
|
+
} & Record<string, unknown>;
|
|
68
|
+
}
|
|
69
|
+
declare function resolveSlackEventBridgeOptions(partial: Partial<SlackEventBridgeOptions>): SlackEventBridgeOptions;
|
|
70
|
+
|
|
71
|
+
export { type SlackEventBridgeOptions as S, resolveSlackEventBridgeOptions as r };
|