@cuylabs/channel-slack 0.5.1 → 0.7.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 +25 -136
- package/dist/app-home.d.ts +23 -0
- package/dist/app-home.js +40 -0
- package/dist/artifacts/index.d.ts +135 -0
- package/dist/artifacts/index.js +299 -0
- package/dist/{assistant.d.ts → assistant/index.d.ts} +1 -1
- package/dist/{assistant.js → assistant/index.js} +2 -2
- package/dist/auth/index.d.ts +56 -0
- package/dist/auth/index.js +168 -0
- package/dist/{chunk-IDVDMJ5U.js → chunk-6JSGIVQH.js} +110 -3
- package/dist/chunk-6WHFQUYQ.js +54 -0
- package/dist/{bolt.js → chunk-73QXT7MA.js} +25 -320
- package/dist/{chunk-CMR6B76C.js → chunk-DNVSH7H5.js} +407 -1
- package/dist/chunk-IRFKUPJN.js +235 -0
- package/dist/chunk-QJYCHWN6.js +76 -0
- package/dist/chunk-S3SWPYXJ.js +81 -0
- package/dist/{chunk-JZG4IETE.js → chunk-X4WBBBYM.js} +0 -52
- package/dist/core.js +5 -3
- package/dist/diagnostics/index.d.ts +71 -0
- package/dist/{diagnostics.js → diagnostics/index.js} +5 -1
- package/dist/entrypoints/index.d.ts +120 -0
- package/dist/entrypoints/index.js +132 -0
- package/dist/{feedback.js → feedback/index.js} +5 -7
- package/dist/{history.d.ts → history/index.d.ts} +2 -2
- package/dist/{history.js → history/index.js} +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +28 -15
- package/dist/{policy.d.ts → policy/index.d.ts} +103 -2
- package/dist/{policy.js → policy/index.js} +13 -1
- package/dist/runtime-BNBHOZSQ.d.ts +53 -0
- package/dist/{setup.d.ts → setup/index.d.ts} +30 -3
- package/dist/{setup.js → setup/index.js} +137 -3
- package/dist/transports/http/index.d.ts +68 -0
- package/dist/transports/http/index.js +8 -0
- package/dist/transports/index.d.ts +8 -0
- package/dist/transports/index.js +24 -0
- package/dist/transports/socket/index.d.ts +94 -0
- package/dist/transports/socket/index.js +19 -0
- package/dist/types-B9NfCVrk.d.ts +141 -0
- package/dist/views/index.d.ts +98 -0
- package/dist/views/index.js +22 -0
- package/docs/README.md +32 -0
- package/docs/concepts/activity.md +3 -3
- package/docs/concepts/artifacts.md +56 -0
- package/docs/concepts/entrypoints.md +73 -0
- package/docs/concepts/setup-requirements.md +23 -0
- package/docs/concepts/{bolt-runtime.md → transport-runtime.md} +9 -4
- package/docs/concepts/views.md +46 -0
- package/docs/recipes/generate-slack-manifest.md +16 -0
- package/docs/recipes/publish-artifact.md +45 -0
- package/docs/recipes/slash-command-and-shortcut.md +51 -0
- package/docs/recipes/socket-mode-app.md +1 -1
- package/docs/reference/channel-slack-boundary.md +10 -6
- package/docs/reference/exports.md +18 -12
- package/docs/reference/source-layout.md +36 -0
- package/package.json +68 -39
- package/dist/bolt.d.ts +0 -364
- package/dist/chunk-NE57BLLU.js +0 -0
- package/dist/diagnostics.d.ts +0 -22
- package/dist/shared.d.ts +0 -2
- package/dist/shared.js +0 -43
- /package/dist/{feedback.d.ts → feedback/index.d.ts} +0 -0
- /package/dist/{targets.d.ts → targets/index.d.ts} +0 -0
- /package/dist/{targets.js → targets/index.js} +0 -0
- /package/dist/{users.d.ts → users/index.d.ts} +0 -0
- /package/dist/{users.js → users/index.js} +0 -0
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import {
|
|
2
|
+
normalizeSlackEventsPath,
|
|
3
|
+
resolveDirectAuth,
|
|
4
|
+
trimToUndefined
|
|
5
|
+
} from "./chunk-S3SWPYXJ.js";
|
|
6
|
+
|
|
7
|
+
// src/transports/http/bolt-app.ts
|
|
8
|
+
async function createSlackBoltApp(options = {}) {
|
|
9
|
+
const boltModule = await import("@slack/bolt");
|
|
10
|
+
const routePath = normalizeSlackEventsPath(options.path ?? "/slack/events");
|
|
11
|
+
const signingSecret = trimToUndefined(
|
|
12
|
+
options.signingSecret ?? process.env.SLACK_SIGNING_SECRET
|
|
13
|
+
);
|
|
14
|
+
if (!signingSecret) {
|
|
15
|
+
throw new Error(
|
|
16
|
+
"Slack signing secret is required. Pass `signingSecret` or set SLACK_SIGNING_SECRET."
|
|
17
|
+
);
|
|
18
|
+
}
|
|
19
|
+
const auth = resolveDirectAuth(options);
|
|
20
|
+
const receiver = new boltModule.ExpressReceiver({
|
|
21
|
+
...options.receiverOptions,
|
|
22
|
+
signingSecret,
|
|
23
|
+
endpoints: routePath,
|
|
24
|
+
processBeforeResponse: options.processBeforeResponse,
|
|
25
|
+
signatureVerification: options.signatureVerification,
|
|
26
|
+
// Bolt is typed against Express 4 while this repo uses Express 5 types.
|
|
27
|
+
// The runtime contract is compatible; keep the cast localized here.
|
|
28
|
+
app: options.app,
|
|
29
|
+
...auth.mode === "oauth" ? {
|
|
30
|
+
clientId: auth.clientId,
|
|
31
|
+
clientSecret: auth.clientSecret,
|
|
32
|
+
stateSecret: auth.stateSecret,
|
|
33
|
+
installationStore: auth.installationStore,
|
|
34
|
+
redirectUri: auth.redirectUri,
|
|
35
|
+
scopes: auth.scopes,
|
|
36
|
+
installerOptions: {
|
|
37
|
+
stateStore: auth.stateStore,
|
|
38
|
+
stateVerification: auth.stateVerification,
|
|
39
|
+
legacyStateVerification: auth.legacyStateVerification,
|
|
40
|
+
stateCookieName: auth.stateCookieName,
|
|
41
|
+
stateCookieExpirationSeconds: auth.stateCookieExpirationSeconds,
|
|
42
|
+
metadata: auth.metadata,
|
|
43
|
+
userScopes: auth.userScopes,
|
|
44
|
+
installPath: auth.installPath,
|
|
45
|
+
redirectUriPath: auth.callbackPath,
|
|
46
|
+
renderHtmlForInstallPath: auth.renderHtmlForInstallPath,
|
|
47
|
+
installPathOptions: auth.installPathOptions,
|
|
48
|
+
callbackOptions: auth.callbackOptions,
|
|
49
|
+
directInstall: auth.directInstall,
|
|
50
|
+
authVersion: auth.authVersion,
|
|
51
|
+
authorizationUrl: auth.authorizationUrl
|
|
52
|
+
}
|
|
53
|
+
} : {}
|
|
54
|
+
});
|
|
55
|
+
const boltApp = new boltModule.App({
|
|
56
|
+
...options.boltAppOptions,
|
|
57
|
+
receiver,
|
|
58
|
+
...auth.mode === "single-workspace" ? {
|
|
59
|
+
token: auth.botToken,
|
|
60
|
+
botId: auth.botId,
|
|
61
|
+
botUserId: auth.botUserId
|
|
62
|
+
} : {},
|
|
63
|
+
...auth.mode === "authorize" ? { authorize: auth.authorize } : {}
|
|
64
|
+
});
|
|
65
|
+
return {
|
|
66
|
+
boltApp,
|
|
67
|
+
receiver,
|
|
68
|
+
app: options.app ?? receiver.app,
|
|
69
|
+
authMode: auth.mode,
|
|
70
|
+
routePath
|
|
71
|
+
};
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
export {
|
|
75
|
+
createSlackBoltApp
|
|
76
|
+
};
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
// src/auth/resolve.ts
|
|
2
|
+
function resolveDirectAuth(options) {
|
|
3
|
+
const provided = options.auth;
|
|
4
|
+
if (!provided || provided.mode === void 0 || provided.mode === "single-workspace") {
|
|
5
|
+
const singleWorkspace = provided;
|
|
6
|
+
const botToken = firstNonEmptyString(
|
|
7
|
+
singleWorkspace?.botToken,
|
|
8
|
+
options.botToken,
|
|
9
|
+
process.env.SLACK_BOT_TOKEN
|
|
10
|
+
);
|
|
11
|
+
if (!botToken) {
|
|
12
|
+
throw new Error(
|
|
13
|
+
'Slack bot token is required for single-workspace mode. Pass `botToken`, use `auth: { mode: "oauth", ... }`, or use `auth: { mode: "authorize", ... }`.'
|
|
14
|
+
);
|
|
15
|
+
}
|
|
16
|
+
return {
|
|
17
|
+
mode: "single-workspace",
|
|
18
|
+
botToken,
|
|
19
|
+
botId: singleWorkspace?.botId,
|
|
20
|
+
botUserId: singleWorkspace?.botUserId
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
if (provided.mode === "authorize") {
|
|
24
|
+
return provided;
|
|
25
|
+
}
|
|
26
|
+
const oauth = provided;
|
|
27
|
+
const clientId = firstNonEmptyString(
|
|
28
|
+
oauth.clientId,
|
|
29
|
+
process.env.SLACK_CLIENT_ID
|
|
30
|
+
);
|
|
31
|
+
const clientSecret = firstNonEmptyString(
|
|
32
|
+
oauth.clientSecret,
|
|
33
|
+
process.env.SLACK_CLIENT_SECRET
|
|
34
|
+
);
|
|
35
|
+
if (!clientId || !clientSecret) {
|
|
36
|
+
throw new Error(
|
|
37
|
+
"Slack OAuth mode requires `clientId` and `clientSecret` or SLACK_CLIENT_ID / SLACK_CLIENT_SECRET."
|
|
38
|
+
);
|
|
39
|
+
}
|
|
40
|
+
if (oauth.stateVerification !== false && !trimToUndefined(oauth.stateSecret) && !oauth.stateStore && !trimToUndefined(process.env.SLACK_STATE_SECRET)) {
|
|
41
|
+
throw new Error(
|
|
42
|
+
"Slack OAuth mode requires `stateSecret` or a custom `stateStore` when state verification is enabled."
|
|
43
|
+
);
|
|
44
|
+
}
|
|
45
|
+
return {
|
|
46
|
+
...oauth,
|
|
47
|
+
mode: "oauth",
|
|
48
|
+
clientId,
|
|
49
|
+
clientSecret,
|
|
50
|
+
stateSecret: firstNonEmptyString(
|
|
51
|
+
oauth.stateSecret,
|
|
52
|
+
process.env.SLACK_STATE_SECRET
|
|
53
|
+
)
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
function normalizeSlackEventsPath(path) {
|
|
57
|
+
const trimmed = path.trim();
|
|
58
|
+
if (!trimmed) {
|
|
59
|
+
throw new Error("Slack events path must not be empty.");
|
|
60
|
+
}
|
|
61
|
+
return trimmed.startsWith("/") ? trimmed : `/${trimmed}`;
|
|
62
|
+
}
|
|
63
|
+
function trimToUndefined(value) {
|
|
64
|
+
const trimmed = value?.trim();
|
|
65
|
+
return trimmed || void 0;
|
|
66
|
+
}
|
|
67
|
+
function firstNonEmptyString(...values) {
|
|
68
|
+
for (const value of values) {
|
|
69
|
+
const trimmed = trimToUndefined(value);
|
|
70
|
+
if (trimmed) {
|
|
71
|
+
return trimmed;
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
return void 0;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
export {
|
|
78
|
+
resolveDirectAuth,
|
|
79
|
+
normalizeSlackEventsPath,
|
|
80
|
+
trimToUndefined
|
|
81
|
+
};
|
|
@@ -1,53 +1,3 @@
|
|
|
1
|
-
// src/shared/formatting.ts
|
|
2
|
-
function resolveSlackMessageFormatter(options) {
|
|
3
|
-
if (options.formatMessageText) {
|
|
4
|
-
return options.formatMessageText;
|
|
5
|
-
}
|
|
6
|
-
if (options.formatChatMarkdown === false) {
|
|
7
|
-
return identity;
|
|
8
|
-
}
|
|
9
|
-
return markdownToSlackMrkdwn;
|
|
10
|
-
}
|
|
11
|
-
function markdownToSlackMrkdwn(markdown) {
|
|
12
|
-
if (!markdown) {
|
|
13
|
-
return markdown;
|
|
14
|
-
}
|
|
15
|
-
const fences = [];
|
|
16
|
-
const withoutFences = markdown.replace(
|
|
17
|
-
/```[^\n`]*\n([\s\S]*?)```/g,
|
|
18
|
-
(_match, code) => {
|
|
19
|
-
const index = fences.push(`\`\`\`
|
|
20
|
-
${code}\`\`\``) - 1;
|
|
21
|
-
return `@@SLACK_FENCE_${index}@@`;
|
|
22
|
-
}
|
|
23
|
-
);
|
|
24
|
-
const boldSegments = [];
|
|
25
|
-
const withBoldPlaceholders = withoutFences.split("\n").map(formatMarkdownLine).join("\n").replace(/\[([^\]\n]+)\]\((https?:\/\/[^)\s]+)\)/g, "<$2|$1>").replace(/\*\*([^*\n]+)\*\*/g, (_match, text) => {
|
|
26
|
-
const index = boldSegments.push(`*${text}*`) - 1;
|
|
27
|
-
return `@@SLACK_BOLD_${index}@@`;
|
|
28
|
-
}).replace(/__([^_\n]+)__/g, (_match, text) => {
|
|
29
|
-
const index = boldSegments.push(`*${text}*`) - 1;
|
|
30
|
-
return `@@SLACK_BOLD_${index}@@`;
|
|
31
|
-
});
|
|
32
|
-
const converted = withBoldPlaceholders.replace(
|
|
33
|
-
/(^|[\s([{"'])\*([^*\n][^*\n]*?)\*(?=[\s.,;:!?)}\]'"]|$)/g,
|
|
34
|
-
"$1_$2_"
|
|
35
|
-
);
|
|
36
|
-
return converted.replace(/@@SLACK_BOLD_(\d+)@@/g, (_match, rawIndex) => {
|
|
37
|
-
const index = Number(rawIndex);
|
|
38
|
-
return boldSegments[index] ?? "";
|
|
39
|
-
}).replace(/@@SLACK_FENCE_(\d+)@@/g, (_match, rawIndex) => {
|
|
40
|
-
const index = Number(rawIndex);
|
|
41
|
-
return fences[index] ?? "";
|
|
42
|
-
});
|
|
43
|
-
}
|
|
44
|
-
function formatMarkdownLine(line) {
|
|
45
|
-
return line.replace(/^(\s*)#{1,6}\s+(.+?)\s*#*\s*$/, "$1**$2**");
|
|
46
|
-
}
|
|
47
|
-
function identity(text) {
|
|
48
|
-
return text;
|
|
49
|
-
}
|
|
50
|
-
|
|
51
1
|
// src/shared/turn-context.ts
|
|
52
2
|
import { AsyncLocalStorage } from "async_hooks";
|
|
53
3
|
var store = new AsyncLocalStorage();
|
|
@@ -132,8 +82,6 @@ function resolveThreadAwareSlackSessionId(info) {
|
|
|
132
82
|
}
|
|
133
83
|
|
|
134
84
|
export {
|
|
135
|
-
resolveSlackMessageFormatter,
|
|
136
|
-
markdownToSlackMrkdwn,
|
|
137
85
|
currentSlackTurnContext,
|
|
138
86
|
runWithSlackTurnContext,
|
|
139
87
|
formatSlackAttributedFollowUp,
|
package/dist/core.js
CHANGED
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
import {
|
|
2
2
|
currentSlackTurnContext,
|
|
3
3
|
formatSlackAttributedFollowUp,
|
|
4
|
-
markdownToSlackMrkdwn,
|
|
5
|
-
resolveSlackMessageFormatter,
|
|
6
4
|
resolveThreadAwareSlackSessionId,
|
|
7
5
|
runWithSlackTurnContext
|
|
8
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-X4WBBBYM.js";
|
|
7
|
+
import {
|
|
8
|
+
markdownToSlackMrkdwn,
|
|
9
|
+
resolveSlackMessageFormatter
|
|
10
|
+
} from "./chunk-6WHFQUYQ.js";
|
|
9
11
|
import {
|
|
10
12
|
extractSlackActionToken,
|
|
11
13
|
extractSlackAuthContext,
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import { g as SlackIdentityExpectations, b as SlackAuthTestIdentity } from '../inspect-BpY5JA0K.js';
|
|
2
|
+
export { I as InspectSlackConnectionOptions, a as InspectSlackTokenScopesOptions, S as SlackApiInspectionError, c as SlackConnectionInspection, d as SlackConnectionInspectionFinding, e as SlackConnectionInspectionFindingSeverity, f as SlackDiagnosticsClient, h as SlackIdentityMismatch, i as SlackScopeInspection, j as SlackScopeInspectionMethod, k as SlackScopeInspectionMethodError, l as SlackTokenSource, m as compareSlackIdentity, n as formatSlackIdentityMismatches, o as inspectSlackConnection, p as inspectSlackTokenScopes, q as normalizeSlackAuthTestIdentity } from '../inspect-BpY5JA0K.js';
|
|
3
|
+
import { d as SlackSocketModeRuntimePolicy } from '../runtime-BNBHOZSQ.js';
|
|
4
|
+
import '@slack/bolt';
|
|
5
|
+
import '../logging-Bl3HfcC8.js';
|
|
6
|
+
|
|
7
|
+
interface SlackPayloadDebugSummary {
|
|
8
|
+
rawArgs: unknown;
|
|
9
|
+
rawArgsActionTokenPaths: string[];
|
|
10
|
+
rawArgsKeyPaths: string[];
|
|
11
|
+
rawArgsTokenLikePaths: string[];
|
|
12
|
+
slackActivity: unknown;
|
|
13
|
+
threadContext: unknown;
|
|
14
|
+
}
|
|
15
|
+
declare function summarizeSlackPayloadDebug({ rawArgs, slackActivity, threadContext, }: {
|
|
16
|
+
rawArgs?: unknown;
|
|
17
|
+
slackActivity: unknown;
|
|
18
|
+
threadContext: unknown;
|
|
19
|
+
}): SlackPayloadDebugSummary;
|
|
20
|
+
declare function selectSlackRawArgsForDebug(rawArgs: unknown): unknown;
|
|
21
|
+
declare function selectSlackBodyForDebug(body: unknown): unknown;
|
|
22
|
+
declare function redactSlackDebugValue(value: unknown, depth?: number): unknown;
|
|
23
|
+
declare function collectJsonKeyPaths(value: unknown): string[];
|
|
24
|
+
declare function findJsonKeyPaths(value: unknown, predicate: (key: string) => boolean): string[];
|
|
25
|
+
|
|
26
|
+
type SlackStartupReadinessTransport = "http" | "socket";
|
|
27
|
+
interface SlackStartupReadinessConfig extends SlackIdentityExpectations {
|
|
28
|
+
authMode: "single-workspace" | string;
|
|
29
|
+
botToken?: string;
|
|
30
|
+
enabled: boolean;
|
|
31
|
+
socketModeRuntimePolicy?: SlackSocketModeRuntimePolicy;
|
|
32
|
+
transport: SlackStartupReadinessTransport;
|
|
33
|
+
}
|
|
34
|
+
interface SlackStartupReadinessOptions {
|
|
35
|
+
clientFactory?: (botToken: string) => SlackStartupAuthTestClient;
|
|
36
|
+
config: SlackStartupReadinessConfig;
|
|
37
|
+
logger?: SlackStartupReadinessLogger;
|
|
38
|
+
}
|
|
39
|
+
interface SlackStartupReadinessResult {
|
|
40
|
+
authMode: string;
|
|
41
|
+
identity?: SlackAuthTestIdentity;
|
|
42
|
+
identityCheck: "disabled" | "passed" | "skipped";
|
|
43
|
+
socketModeRuntimePolicy?: SlackSocketModeRuntimePolicy;
|
|
44
|
+
transport: SlackStartupReadinessTransport;
|
|
45
|
+
}
|
|
46
|
+
interface SlackStartupAuthTestClient {
|
|
47
|
+
auth: {
|
|
48
|
+
test(): Promise<SlackStartupAuthTestResponse>;
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
interface SlackStartupAuthTestResponse {
|
|
52
|
+
bot_id?: string;
|
|
53
|
+
error?: string;
|
|
54
|
+
ok?: boolean;
|
|
55
|
+
team?: string;
|
|
56
|
+
team_id?: string;
|
|
57
|
+
url?: string;
|
|
58
|
+
user_id?: string;
|
|
59
|
+
}
|
|
60
|
+
interface SlackStartupReadinessLogger {
|
|
61
|
+
debug?(message: string, attributes?: Record<string, unknown>): void;
|
|
62
|
+
info?(message: string, attributes?: Record<string, unknown>): void;
|
|
63
|
+
warn?(message: string, attributes?: Record<string, unknown>): void;
|
|
64
|
+
}
|
|
65
|
+
declare class SlackStartupReadinessError extends Error {
|
|
66
|
+
readonly issues: readonly string[];
|
|
67
|
+
constructor(issues: readonly string[]);
|
|
68
|
+
}
|
|
69
|
+
declare function runSlackStartupReadiness({ clientFactory, config, logger, }: SlackStartupReadinessOptions): Promise<SlackStartupReadinessResult>;
|
|
70
|
+
|
|
71
|
+
export { SlackAuthTestIdentity, SlackIdentityExpectations, type SlackPayloadDebugSummary, type SlackStartupAuthTestClient, type SlackStartupAuthTestResponse, type SlackStartupReadinessConfig, SlackStartupReadinessError, type SlackStartupReadinessLogger, type SlackStartupReadinessOptions, type SlackStartupReadinessResult, type SlackStartupReadinessTransport, collectJsonKeyPaths, findJsonKeyPaths, redactSlackDebugValue, runSlackStartupReadiness, selectSlackBodyForDebug, selectSlackRawArgsForDebug, summarizeSlackPayloadDebug };
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import {
|
|
2
|
+
SlackStartupReadinessError,
|
|
2
3
|
collectJsonKeyPaths,
|
|
3
4
|
compareSlackIdentity,
|
|
4
5
|
findJsonKeyPaths,
|
|
@@ -7,11 +8,13 @@ import {
|
|
|
7
8
|
inspectSlackTokenScopes,
|
|
8
9
|
normalizeSlackAuthTestIdentity,
|
|
9
10
|
redactSlackDebugValue,
|
|
11
|
+
runSlackStartupReadiness,
|
|
10
12
|
selectSlackBodyForDebug,
|
|
11
13
|
selectSlackRawArgsForDebug,
|
|
12
14
|
summarizeSlackPayloadDebug
|
|
13
|
-
} from "
|
|
15
|
+
} from "../chunk-6JSGIVQH.js";
|
|
14
16
|
export {
|
|
17
|
+
SlackStartupReadinessError,
|
|
15
18
|
collectJsonKeyPaths,
|
|
16
19
|
compareSlackIdentity,
|
|
17
20
|
findJsonKeyPaths,
|
|
@@ -20,6 +23,7 @@ export {
|
|
|
20
23
|
inspectSlackTokenScopes,
|
|
21
24
|
normalizeSlackAuthTestIdentity,
|
|
22
25
|
redactSlackDebugValue,
|
|
26
|
+
runSlackStartupReadiness,
|
|
23
27
|
selectSlackBodyForDebug,
|
|
24
28
|
selectSlackRawArgsForDebug,
|
|
25
29
|
summarizeSlackPayloadDebug
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
import { S as SlackActivityInfo } from '../activity-ByrD9Ftr.js';
|
|
2
|
+
|
|
3
|
+
interface RawSlackSlashCommandPayload {
|
|
4
|
+
command?: string;
|
|
5
|
+
text?: string;
|
|
6
|
+
response_url?: string;
|
|
7
|
+
trigger_id?: string;
|
|
8
|
+
user_id?: string;
|
|
9
|
+
user_name?: string;
|
|
10
|
+
team_id?: string;
|
|
11
|
+
team_domain?: string;
|
|
12
|
+
channel_id?: string;
|
|
13
|
+
channel_name?: string;
|
|
14
|
+
api_app_id?: string;
|
|
15
|
+
enterprise_id?: string;
|
|
16
|
+
enterprise_name?: string;
|
|
17
|
+
is_enterprise_install?: string | boolean;
|
|
18
|
+
[key: string]: unknown;
|
|
19
|
+
}
|
|
20
|
+
interface SlackSlashCommandEntrypoint {
|
|
21
|
+
kind: "slash-command";
|
|
22
|
+
command: string;
|
|
23
|
+
activity: SlackActivityInfo;
|
|
24
|
+
triggerId?: string;
|
|
25
|
+
responseUrl?: string;
|
|
26
|
+
userName?: string;
|
|
27
|
+
channelName?: string;
|
|
28
|
+
teamDomain?: string;
|
|
29
|
+
appId?: string;
|
|
30
|
+
enterpriseId?: string;
|
|
31
|
+
enterpriseName?: string;
|
|
32
|
+
isEnterpriseInstall?: boolean;
|
|
33
|
+
}
|
|
34
|
+
declare function parseSlackSlashCommandEntrypoint(payload: RawSlackSlashCommandPayload): SlackSlashCommandEntrypoint;
|
|
35
|
+
|
|
36
|
+
interface RawSlackShortcutUser {
|
|
37
|
+
id?: string;
|
|
38
|
+
name?: string;
|
|
39
|
+
username?: string;
|
|
40
|
+
team_id?: string;
|
|
41
|
+
[key: string]: unknown;
|
|
42
|
+
}
|
|
43
|
+
interface RawSlackShortcutTeam {
|
|
44
|
+
id?: string;
|
|
45
|
+
domain?: string;
|
|
46
|
+
enterprise_id?: string;
|
|
47
|
+
enterprise_name?: string;
|
|
48
|
+
[key: string]: unknown;
|
|
49
|
+
}
|
|
50
|
+
interface RawSlackShortcutEnterprise {
|
|
51
|
+
id?: string;
|
|
52
|
+
name?: string;
|
|
53
|
+
[key: string]: unknown;
|
|
54
|
+
}
|
|
55
|
+
interface RawSlackShortcutChannel {
|
|
56
|
+
id?: string;
|
|
57
|
+
name?: string;
|
|
58
|
+
[key: string]: unknown;
|
|
59
|
+
}
|
|
60
|
+
interface RawSlackShortcutMessage {
|
|
61
|
+
type?: string;
|
|
62
|
+
user?: string;
|
|
63
|
+
channel?: string;
|
|
64
|
+
ts?: string;
|
|
65
|
+
thread_ts?: string;
|
|
66
|
+
text?: string;
|
|
67
|
+
blocks?: unknown[];
|
|
68
|
+
attachments?: unknown[];
|
|
69
|
+
[key: string]: unknown;
|
|
70
|
+
}
|
|
71
|
+
interface RawSlackShortcutPayload {
|
|
72
|
+
type?: "shortcut" | "message_action" | string;
|
|
73
|
+
callback_id?: string;
|
|
74
|
+
trigger_id?: string;
|
|
75
|
+
response_url?: string;
|
|
76
|
+
action_ts?: string;
|
|
77
|
+
message_ts?: string;
|
|
78
|
+
user?: RawSlackShortcutUser;
|
|
79
|
+
team?: RawSlackShortcutTeam | null;
|
|
80
|
+
enterprise?: RawSlackShortcutEnterprise;
|
|
81
|
+
channel?: RawSlackShortcutChannel;
|
|
82
|
+
message?: RawSlackShortcutMessage;
|
|
83
|
+
is_enterprise_install?: boolean;
|
|
84
|
+
[key: string]: unknown;
|
|
85
|
+
}
|
|
86
|
+
interface SlackShortcutEntrypointBase {
|
|
87
|
+
callbackId: string;
|
|
88
|
+
triggerId?: string;
|
|
89
|
+
actionTs?: string;
|
|
90
|
+
userId: string;
|
|
91
|
+
userName?: string;
|
|
92
|
+
teamId?: string;
|
|
93
|
+
teamDomain?: string;
|
|
94
|
+
enterpriseId?: string;
|
|
95
|
+
enterpriseName?: string;
|
|
96
|
+
isEnterpriseInstall?: boolean;
|
|
97
|
+
}
|
|
98
|
+
interface SlackGlobalShortcutEntrypoint extends SlackShortcutEntrypointBase {
|
|
99
|
+
kind: "global-shortcut";
|
|
100
|
+
}
|
|
101
|
+
interface SlackMessageShortcutSelection {
|
|
102
|
+
channelId: string;
|
|
103
|
+
channelName?: string;
|
|
104
|
+
messageTs?: string;
|
|
105
|
+
threadTs?: string;
|
|
106
|
+
userId?: string;
|
|
107
|
+
text: string;
|
|
108
|
+
}
|
|
109
|
+
interface SlackMessageShortcutEntrypoint extends SlackShortcutEntrypointBase {
|
|
110
|
+
kind: "message-shortcut";
|
|
111
|
+
activity: SlackActivityInfo;
|
|
112
|
+
responseUrl?: string;
|
|
113
|
+
selectedMessage: SlackMessageShortcutSelection;
|
|
114
|
+
}
|
|
115
|
+
type SlackShortcutEntrypoint = SlackGlobalShortcutEntrypoint | SlackMessageShortcutEntrypoint;
|
|
116
|
+
declare function parseSlackShortcutEntrypoint(payload: RawSlackShortcutPayload): SlackShortcutEntrypoint;
|
|
117
|
+
declare function parseSlackGlobalShortcutEntrypoint(payload: RawSlackShortcutPayload): SlackGlobalShortcutEntrypoint;
|
|
118
|
+
declare function parseSlackMessageShortcutEntrypoint(payload: RawSlackShortcutPayload): SlackMessageShortcutEntrypoint;
|
|
119
|
+
|
|
120
|
+
export { type RawSlackShortcutChannel, type RawSlackShortcutEnterprise, type RawSlackShortcutMessage, type RawSlackShortcutPayload, type RawSlackShortcutTeam, type RawSlackShortcutUser, type RawSlackSlashCommandPayload, type SlackGlobalShortcutEntrypoint, type SlackMessageShortcutEntrypoint, type SlackMessageShortcutSelection, type SlackShortcutEntrypoint, type SlackShortcutEntrypointBase, type SlackSlashCommandEntrypoint, parseSlackGlobalShortcutEntrypoint, parseSlackMessageShortcutEntrypoint, parseSlackShortcutEntrypoint, parseSlackSlashCommandEntrypoint };
|
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
import {
|
|
2
|
+
extractSlackMessageText,
|
|
3
|
+
resolveSlackChannelType
|
|
4
|
+
} from "../chunk-FPCE5V5Y.js";
|
|
5
|
+
|
|
6
|
+
// src/entrypoints/commands.ts
|
|
7
|
+
function parseSlackSlashCommandEntrypoint(payload) {
|
|
8
|
+
const channelId = readString(payload.channel_id) ?? "unknown";
|
|
9
|
+
const teamId = readString(payload.team_id);
|
|
10
|
+
const text = readString(payload.text) ?? "";
|
|
11
|
+
const triggerId = readString(payload.trigger_id);
|
|
12
|
+
const responseUrl = readString(payload.response_url);
|
|
13
|
+
const userName = readString(payload.user_name);
|
|
14
|
+
const channelName = readString(payload.channel_name);
|
|
15
|
+
const teamDomain = readString(payload.team_domain);
|
|
16
|
+
const appId = readString(payload.api_app_id);
|
|
17
|
+
const enterpriseId = readString(payload.enterprise_id);
|
|
18
|
+
const enterpriseName = readString(payload.enterprise_name);
|
|
19
|
+
const activity = {
|
|
20
|
+
channelId,
|
|
21
|
+
channelType: resolveSlackChannelType(channelId, void 0, false),
|
|
22
|
+
userId: readString(payload.user_id) ?? "unknown",
|
|
23
|
+
...teamId ? { teamId } : {},
|
|
24
|
+
text,
|
|
25
|
+
isMention: false
|
|
26
|
+
};
|
|
27
|
+
return {
|
|
28
|
+
kind: "slash-command",
|
|
29
|
+
command: readString(payload.command) ?? "unknown",
|
|
30
|
+
activity,
|
|
31
|
+
...triggerId ? { triggerId } : {},
|
|
32
|
+
...responseUrl ? { responseUrl } : {},
|
|
33
|
+
...userName ? { userName } : {},
|
|
34
|
+
...channelName ? { channelName } : {},
|
|
35
|
+
...teamDomain ? { teamDomain } : {},
|
|
36
|
+
...appId ? { appId } : {},
|
|
37
|
+
...enterpriseId ? { enterpriseId } : {},
|
|
38
|
+
...enterpriseName ? { enterpriseName } : {},
|
|
39
|
+
...payload.is_enterprise_install !== void 0 ? {
|
|
40
|
+
isEnterpriseInstall: payload.is_enterprise_install === true || payload.is_enterprise_install === "true"
|
|
41
|
+
} : {}
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
function readString(value) {
|
|
45
|
+
return typeof value === "string" && value.trim() ? value.trim() : void 0;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
// src/entrypoints/shortcuts.ts
|
|
49
|
+
function parseSlackShortcutEntrypoint(payload) {
|
|
50
|
+
return payload.type === "message_action" || payload.message ? parseSlackMessageShortcutEntrypoint(payload) : parseSlackGlobalShortcutEntrypoint(payload);
|
|
51
|
+
}
|
|
52
|
+
function parseSlackGlobalShortcutEntrypoint(payload) {
|
|
53
|
+
return {
|
|
54
|
+
kind: "global-shortcut",
|
|
55
|
+
...parseShortcutBase(payload)
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
function parseSlackMessageShortcutEntrypoint(payload) {
|
|
59
|
+
const base = parseShortcutBase(payload);
|
|
60
|
+
const message = readRecord(payload.message) ?? {};
|
|
61
|
+
const channel = readRecord(payload.channel);
|
|
62
|
+
const channelId = readString2(channel?.id) ?? readString2(message.channel) ?? "unknown";
|
|
63
|
+
const messageTs = readString2(payload.message_ts) ?? readString2(message.ts) ?? void 0;
|
|
64
|
+
const threadTs = readString2(message.thread_ts);
|
|
65
|
+
const isThread = Boolean(threadTs && threadTs !== messageTs);
|
|
66
|
+
const responseUrl = readString2(payload.response_url);
|
|
67
|
+
const channelName = readString2(channel?.name);
|
|
68
|
+
const selectedMessageUserId = readString2(message.user);
|
|
69
|
+
const text = extractSlackMessageText(message, {
|
|
70
|
+
stripLeadingMentions: channelId.startsWith("D") ? false : true
|
|
71
|
+
});
|
|
72
|
+
const activity = {
|
|
73
|
+
channelId,
|
|
74
|
+
channelType: resolveSlackChannelType(channelId, threadTs, isThread),
|
|
75
|
+
userId: base.userId,
|
|
76
|
+
...base.teamId ? { teamId: base.teamId } : {},
|
|
77
|
+
...isThread ? { threadTs } : {},
|
|
78
|
+
...messageTs ? { messageTs } : {},
|
|
79
|
+
text,
|
|
80
|
+
isMention: false
|
|
81
|
+
};
|
|
82
|
+
return {
|
|
83
|
+
kind: "message-shortcut",
|
|
84
|
+
...base,
|
|
85
|
+
activity,
|
|
86
|
+
...responseUrl ? { responseUrl } : {},
|
|
87
|
+
selectedMessage: {
|
|
88
|
+
channelId,
|
|
89
|
+
...channelName ? { channelName } : {},
|
|
90
|
+
...messageTs ? { messageTs } : {},
|
|
91
|
+
...threadTs ? { threadTs } : {},
|
|
92
|
+
...selectedMessageUserId ? { userId: selectedMessageUserId } : {},
|
|
93
|
+
text
|
|
94
|
+
}
|
|
95
|
+
};
|
|
96
|
+
}
|
|
97
|
+
function parseShortcutBase(payload) {
|
|
98
|
+
const user = readRecord(payload.user);
|
|
99
|
+
const team = readRecord(payload.team);
|
|
100
|
+
const enterprise = readRecord(payload.enterprise);
|
|
101
|
+
const teamId = readString2(team?.id) ?? readString2(user?.team_id);
|
|
102
|
+
const enterpriseId = readString2(enterprise?.id) ?? readString2(team?.enterprise_id);
|
|
103
|
+
const enterpriseName = readString2(enterprise?.name) ?? readString2(team?.enterprise_name);
|
|
104
|
+
const triggerId = readString2(payload.trigger_id);
|
|
105
|
+
const actionTs = readString2(payload.action_ts);
|
|
106
|
+
const userName = readString2(user?.name) ?? readString2(user?.username);
|
|
107
|
+
const teamDomain = readString2(team?.domain);
|
|
108
|
+
return {
|
|
109
|
+
callbackId: readString2(payload.callback_id) ?? "unknown",
|
|
110
|
+
userId: readString2(user?.id) ?? "unknown",
|
|
111
|
+
...triggerId ? { triggerId } : {},
|
|
112
|
+
...actionTs ? { actionTs } : {},
|
|
113
|
+
...userName ? { userName } : {},
|
|
114
|
+
...teamId ? { teamId } : {},
|
|
115
|
+
...teamDomain ? { teamDomain } : {},
|
|
116
|
+
...enterpriseId ? { enterpriseId } : {},
|
|
117
|
+
...enterpriseName ? { enterpriseName } : {},
|
|
118
|
+
...payload.is_enterprise_install !== void 0 ? { isEnterpriseInstall: payload.is_enterprise_install } : {}
|
|
119
|
+
};
|
|
120
|
+
}
|
|
121
|
+
function readRecord(value) {
|
|
122
|
+
return value && typeof value === "object" && !Array.isArray(value) ? value : void 0;
|
|
123
|
+
}
|
|
124
|
+
function readString2(value) {
|
|
125
|
+
return typeof value === "string" && value.trim() ? value.trim() : void 0;
|
|
126
|
+
}
|
|
127
|
+
export {
|
|
128
|
+
parseSlackGlobalShortcutEntrypoint,
|
|
129
|
+
parseSlackMessageShortcutEntrypoint,
|
|
130
|
+
parseSlackShortcutEntrypoint,
|
|
131
|
+
parseSlackSlashCommandEntrypoint
|
|
132
|
+
};
|
|
@@ -1,3 +1,7 @@
|
|
|
1
|
+
import {
|
|
2
|
+
openSlackModal
|
|
3
|
+
} from "../chunk-IRFKUPJN.js";
|
|
4
|
+
|
|
1
5
|
// src/feedback/block.ts
|
|
2
6
|
var SLACK_FEEDBACK_ACTION_ID = "agent_feedback";
|
|
3
7
|
function createSlackFeedbackBlock(options = {}) {
|
|
@@ -76,13 +80,7 @@ function registerSlackFeedbackAction(app, options) {
|
|
|
76
80
|
"Slack feedback payload did not include trigger_id."
|
|
77
81
|
);
|
|
78
82
|
}
|
|
79
|
-
|
|
80
|
-
throw new Error("Slack client does not expose views.open.");
|
|
81
|
-
}
|
|
82
|
-
await client.views.open({
|
|
83
|
-
trigger_id: triggerId,
|
|
84
|
-
view
|
|
85
|
-
});
|
|
83
|
+
await openSlackModal({ client, triggerId, view });
|
|
86
84
|
};
|
|
87
85
|
const acknowledgeEphemeral = async (text) => {
|
|
88
86
|
await client.chat.postEphemeral({
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { S as SlackActivityInfo } from '
|
|
1
|
+
import { S as SlackActivityInfo } from '../activity-ByrD9Ftr.js';
|
|
2
2
|
import { ConversationsHistoryResponse, ConversationsRepliesResponse, WebClient } from '@slack/web-api';
|
|
3
|
-
import { L as Logger } from '
|
|
3
|
+
import { L as Logger } from '../logging-Bl3HfcC8.js';
|
|
4
4
|
|
|
5
5
|
type SlackContextFragmentRole = "system" | "user";
|
|
6
6
|
type SlackContextFragmentPlacement = "before-history" | "after-latest-user" | "after-history";
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
export { S as SlackActivityInfo, a as SlackChannelType, b as SlackUserIdentity } from './activity-ByrD9Ftr.js';
|
|
2
2
|
export { ExtractSlackMessageTextOptions, RawSlackActionTokenPayload, RawSlackAppMentionPayload, RawSlackAssistantThreadPayload, RawSlackMessagePayload, SlackAmbientTurnContext, SlackApprovalRequest, SlackAssistantStatusUpdate, SlackAssistantSuggestedPrompt, SlackAssistantSuggestedPrompts, SlackAssistantTaskDisplayMode, SlackAssistantThreadContext, SlackAssistantUtilities, SlackAuthContext, SlackChatStreamStartArgs, SlackEventInteractiveRequestHandler, SlackHumanInputRequest, SlackInteractiveMessage, SlackInteractiveMessageRef, SlackInteractiveRequest, SlackInteractiveRequestBaseContext, SlackInteractiveRequestContext, SlackInteractiveRequestHandler, SlackInteractiveRequestKind, SlackInteractiveResponder, SlackMessageAuthorshipOptions, SlackMessageFormatter, SlackMessageFormattingOptions, SlackMessageTextPayload, SlackThreadStatusSetter, SlackTurnPreparation, SlackTurnRequestContext, currentSlackTurnContext, extractSlackActionToken, extractSlackAttachmentsText, extractSlackAuthContext, extractSlackBlocksText, extractSlackMessageText, extractSlackUserIdentity, formatSlackAttributedFollowUp, isProcessableMessage, markdownToSlackMrkdwn, parseSlackMentionActivity, parseSlackMessageActivity, resolveSlackChannelType, resolveSlackMessageFormatter, resolveThreadAwareSlackSessionId, runWithSlackTurnContext, stripLeadingMentions } from './core.js';
|
|
3
|
-
export { PostgresSlackMessagePolicyPruneResult, PostgresSlackMessagePolicyStateStore, PostgresSlackMessagePolicyStateStoreOptions, SlackAsyncMessagePolicyConfig, SlackAsyncMessagePolicyResolver, SlackChannelMessagePolicy, SlackMentionedThreadState, SlackMessagePolicyAcceptReason, SlackMessagePolicyAcceptedDecision, SlackMessagePolicyConfig, SlackMessagePolicyDecision, SlackMessagePolicyPostgresClient, SlackMessagePolicyRejectReason, SlackMessagePolicyRejectedDecision, SlackMessagePolicyResolver, SlackMessagePolicyStateContext, SlackMessagePolicyStateStore, SlackSyncMessagePolicyStateStore, SlackThreadReplyPolicy, createAsyncSlackMessagePolicyResolver, createInMemorySlackMessagePolicyStateStore, createPostgresSlackMessagePolicyStateStore, createSlackMessagePolicyMessageKey, createSlackMessagePolicyResolver, createSlackMessagePolicyThreadKey, initializePostgresSlackMessagePolicyState, prunePostgresSlackMessagePolicyState, shouldRegisterSlackPassiveChannelMessages } from './policy.js';
|
|
3
|
+
export { InMemorySlackThreadParticipationStateStoreOptions, PostgresSlackMessagePolicyPruneResult, PostgresSlackMessagePolicyStateStore, PostgresSlackMessagePolicyStateStoreOptions, PostgresSlackThreadParticipationStateStore, PostgresSlackThreadParticipationStateStoreOptions, SlackAsyncMessagePolicyConfig, SlackAsyncMessagePolicyResolver, SlackChannelMessagePolicy, SlackMentionedThreadState, SlackMessagePolicyAcceptReason, SlackMessagePolicyAcceptedDecision, SlackMessagePolicyConfig, SlackMessagePolicyDecision, SlackMessagePolicyPostgresClient, SlackMessagePolicyRejectReason, SlackMessagePolicyRejectedDecision, SlackMessagePolicyResolver, SlackMessagePolicyStateContext, SlackMessagePolicyStateStore, SlackQuietThreadRejectedDecision, SlackSyncMessagePolicyStateStore, SlackThreadAwareMessagePolicyConfig, SlackThreadAwareMessagePolicyDecision, SlackThreadAwareMessagePolicyResolver, SlackThreadParticipationEligibility, SlackThreadParticipationEligibilityOptions, SlackThreadParticipationMode, SlackThreadParticipationPostgresClient, SlackThreadParticipationPruneResult, SlackThreadParticipationReactivation, SlackThreadParticipationState, SlackThreadParticipationStateContext, SlackThreadParticipationStateStore, SlackThreadReplyPolicy, createAsyncSlackMessagePolicyResolver, createAsyncSlackThreadAwareMessagePolicyResolver, createInMemorySlackMessagePolicyStateStore, createInMemorySlackThreadParticipationStateStore, createPostgresSlackMessagePolicyStateStore, createPostgresSlackThreadParticipationStateStore, createSlackMessagePolicyMessageKey, createSlackMessagePolicyResolver, createSlackMessagePolicyThreadKey, initializePostgresSlackMessagePolicyState, initializePostgresSlackThreadParticipationState, prunePostgresSlackMessagePolicyState, prunePostgresSlackThreadParticipationState, resolveSlackThreadParticipationEligibility, shouldRegisterSlackPassiveChannelMessages } from './policy/index.js';
|
|
4
4
|
export { L as Logger } from './logging-Bl3HfcC8.js';
|