@cuylabs/channel-slack-agent-core 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 +13 -10
- package/dist/chunk-U6RC4SXN.js +331 -0
- package/dist/history/index.d.ts +7 -17
- package/dist/index.d.ts +5 -28
- package/dist/index.js +14 -58
- package/dist/interactive/index.d.ts +86 -7
- package/dist/shared/index.d.ts +144 -19
- package/dist/shared/index.js +8 -4
- package/docs/README.md +0 -1
- package/docs/concepts/final-response-artifacts.md +9 -7
- package/docs/concepts/tool-task-rendering.md +2 -0
- package/docs/reference/exports.md +10 -20
- package/package.json +4 -54
- package/dist/adapter/index.d.ts +0 -26
- package/dist/adapter/index.js +0 -9
- package/dist/adapter-vbqtraAr.d.ts +0 -31
- package/dist/app-surface.d.ts +0 -82
- package/dist/app-surface.js +0 -10
- package/dist/app.d.ts +0 -60
- package/dist/app.js +0 -11
- package/dist/artifacts/index.d.ts +0 -57
- package/dist/artifacts/index.js +0 -6
- package/dist/assistant/index.d.ts +0 -22
- package/dist/assistant/index.js +0 -14
- package/dist/chunk-A2PLAVW6.js +0 -75
- package/dist/chunk-C7CHMYV6.js +0 -226
- package/dist/chunk-D4CSEAIF.js +0 -82
- package/dist/chunk-ELR6MQD7.js +0 -12
- package/dist/chunk-FJP6ZFUB.js +0 -921
- package/dist/chunk-GKZRDNEB.js +0 -187
- package/dist/chunk-HHXAXSG6.js +0 -67
- package/dist/chunk-JU5R6JZG.js +0 -85
- package/dist/chunk-KAEZPS3U.js +0 -77
- package/dist/chunk-NNCVHQC4.js +0 -94
- package/dist/chunk-VBGQD6JT.js +0 -1008
- package/dist/chunk-XA7U3GRN.js +0 -482
- package/dist/express-assistant.d.ts +0 -106
- package/dist/express-assistant.js +0 -9
- package/dist/express.d.ts +0 -103
- package/dist/express.js +0 -8
- package/dist/feedback/index.d.ts +0 -1
- package/dist/feedback/index.js +0 -10
- package/dist/options-ByNm2o89.d.ts +0 -323
- package/dist/options-CGUfVStV.d.ts +0 -119
- package/dist/socket.d.ts +0 -143
- package/dist/socket.js +0 -13
- package/dist/types-BeGPexio.d.ts +0 -381
- package/dist/types-Bz4OYEAV.d.ts +0 -87
- package/dist/types-CiwGU6zC.d.ts +0 -56
- package/dist/views/index.d.ts +0 -8
- package/dist/views/index.js +0 -10
- package/docs/concepts/view-workflows.md +0 -52
|
@@ -1,57 +0,0 @@
|
|
|
1
|
-
import { SlackArtifactClient, SlackArtifactPublication } from '@cuylabs/channel-slack/artifacts';
|
|
2
|
-
|
|
3
|
-
interface SlackFinalResponseArtifactContext {
|
|
4
|
-
text: string;
|
|
5
|
-
formattedText: string;
|
|
6
|
-
client: SlackArtifactClient;
|
|
7
|
-
channelId: string;
|
|
8
|
-
threadTs?: string;
|
|
9
|
-
}
|
|
10
|
-
interface SlackFinalResponseArtifactResult {
|
|
11
|
-
publication: SlackArtifactPublication;
|
|
12
|
-
}
|
|
13
|
-
type SlackFinalResponseArtifactDeliveryMode = "supplemental" | "replace";
|
|
14
|
-
type SlackFinalResponseArtifactPublisher = (context: SlackFinalResponseArtifactContext) => Promise<SlackFinalResponseArtifactResult | undefined>;
|
|
15
|
-
type SlackFinalResponseArtifactValueResolver<T> = T | ((context: SlackFinalResponseArtifactContext) => T | Promise<T>);
|
|
16
|
-
interface CreateSlackFinalResponseArtifactPublisherOptions {
|
|
17
|
-
/**
|
|
18
|
-
* Minimum raw-response characters required before publishing an artifact.
|
|
19
|
-
*
|
|
20
|
-
* @default 4000
|
|
21
|
-
*/
|
|
22
|
-
minCharacters?: number;
|
|
23
|
-
/**
|
|
24
|
-
* Canvas/file title.
|
|
25
|
-
*
|
|
26
|
-
* @default "Agent response"
|
|
27
|
-
*/
|
|
28
|
-
title?: SlackFinalResponseArtifactValueResolver<string | undefined>;
|
|
29
|
-
/**
|
|
30
|
-
* Optional Slack artifact summary.
|
|
31
|
-
*/
|
|
32
|
-
summary?: SlackFinalResponseArtifactValueResolver<string | undefined>;
|
|
33
|
-
/**
|
|
34
|
-
* Prefer creating a channel canvas when the Slack client exposes
|
|
35
|
-
* `conversations.canvases.create`.
|
|
36
|
-
*
|
|
37
|
-
* @default true
|
|
38
|
-
*/
|
|
39
|
-
channelCanvas?: boolean;
|
|
40
|
-
/**
|
|
41
|
-
* Fallback when Canvas publication fails.
|
|
42
|
-
*
|
|
43
|
-
* @default "file"
|
|
44
|
-
*/
|
|
45
|
-
fallback?: "file" | "none";
|
|
46
|
-
/**
|
|
47
|
-
* Called after a Canvas or fallback file is published.
|
|
48
|
-
*/
|
|
49
|
-
onPublished?: (result: SlackFinalResponseArtifactResult, context: SlackFinalResponseArtifactContext) => void | Promise<void>;
|
|
50
|
-
/**
|
|
51
|
-
* Called when Canvas publication fails and no fallback publication succeeds.
|
|
52
|
-
*/
|
|
53
|
-
onError?: (error: unknown, context: SlackFinalResponseArtifactContext) => void | Promise<void>;
|
|
54
|
-
}
|
|
55
|
-
declare function createSlackFinalResponseArtifactPublisher({ minCharacters, title, summary, channelCanvas, fallback, onPublished, onError, }?: CreateSlackFinalResponseArtifactPublisherOptions): SlackFinalResponseArtifactPublisher;
|
|
56
|
-
|
|
57
|
-
export { type CreateSlackFinalResponseArtifactPublisherOptions, type SlackFinalResponseArtifactContext, type SlackFinalResponseArtifactDeliveryMode, type SlackFinalResponseArtifactPublisher, type SlackFinalResponseArtifactResult, type SlackFinalResponseArtifactValueResolver, createSlackFinalResponseArtifactPublisher };
|
package/dist/artifacts/index.js
DELETED
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import { C as CreateSlackAssistantBridgeOptions, S as SlackAssistantBridge } from '../options-ByNm2o89.js';
|
|
2
|
-
export { A as AssistantLifecycleArgs, a as AssistantThreadStartedArgs, M as MaybePromise, b as SlackAssistantCancelControlOptions, c as SlackAssistantCancelControlVisibleWhen, d as SlackAssistantFeedbackConfig, e as SlackAssistantSessionStrategy, f as SlackAssistantStatusContext, g as SlackAssistantThreadContextStoreLike, h as SlackAssistantThreadStartedContext, i as SlackAssistantTurnCancelContext, j as SlackAssistantTurnControlsOptions, k as SlackAssistantTurnPreparation, l as SlackAssistantUserMessageContext, r as resolveAssistantSessionId } from '../options-ByNm2o89.js';
|
|
3
|
-
export { ParsedAssistantUserMessage, createSlackAssistantThreadContextStore, parseSlackMessageActivityFromMessageEvent } from '@cuylabs/channel-slack/assistant';
|
|
4
|
-
import '@cuylabs/agent-core';
|
|
5
|
-
import '@slack/bolt';
|
|
6
|
-
import '@slack/web-api';
|
|
7
|
-
import '@cuylabs/channel-slack/core';
|
|
8
|
-
import '../interactive-BigrPKnu.js';
|
|
9
|
-
import '@cuylabs/channel-slack/interactive';
|
|
10
|
-
import '../options-CGUfVStV.js';
|
|
11
|
-
import '../artifacts/index.js';
|
|
12
|
-
import '@cuylabs/channel-slack/artifacts';
|
|
13
|
-
import '@cuylabs/channel-slack/feedback';
|
|
14
|
-
|
|
15
|
-
/**
|
|
16
|
-
* `createSlackAssistantBridge` factory — assembles the three lifecycle
|
|
17
|
-
* middlewares into a Bolt `Assistant` and wires the feedback action handler.
|
|
18
|
-
*/
|
|
19
|
-
|
|
20
|
-
declare function createSlackAssistantBridge(options: CreateSlackAssistantBridgeOptions): SlackAssistantBridge;
|
|
21
|
-
|
|
22
|
-
export { CreateSlackAssistantBridgeOptions, SlackAssistantBridge, createSlackAssistantBridge };
|
package/dist/assistant/index.js
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
createSlackAssistantBridge,
|
|
3
|
-
createSlackAssistantThreadContextStore,
|
|
4
|
-
parseSlackMessageActivityFromMessageEvent,
|
|
5
|
-
resolveAssistantSessionId
|
|
6
|
-
} from "../chunk-FJP6ZFUB.js";
|
|
7
|
-
import "../chunk-ELR6MQD7.js";
|
|
8
|
-
import "../chunk-VBGQD6JT.js";
|
|
9
|
-
export {
|
|
10
|
-
createSlackAssistantBridge,
|
|
11
|
-
createSlackAssistantThreadContextStore,
|
|
12
|
-
parseSlackMessageActivityFromMessageEvent,
|
|
13
|
-
resolveAssistantSessionId
|
|
14
|
-
};
|
package/dist/chunk-A2PLAVW6.js
DELETED
|
@@ -1,75 +0,0 @@
|
|
|
1
|
-
// src/shared/context-fragments.ts
|
|
2
|
-
import {
|
|
3
|
-
currentSlackTurnContext
|
|
4
|
-
} from "@cuylabs/channel-slack/core";
|
|
5
|
-
var DEFAULT_SLACK_CONTEXT_FRAGMENT_KEY = "slackContextFragment";
|
|
6
|
-
function isRecord(value) {
|
|
7
|
-
return Boolean(value) && typeof value === "object" && !Array.isArray(value);
|
|
8
|
-
}
|
|
9
|
-
function isPayload(value) {
|
|
10
|
-
return isRecord(value) && typeof value.content === "string";
|
|
11
|
-
}
|
|
12
|
-
function resolveContextBagValue(slack, key) {
|
|
13
|
-
const value = slack.context?.[key];
|
|
14
|
-
if (typeof value === "string") {
|
|
15
|
-
return value;
|
|
16
|
-
}
|
|
17
|
-
if (isPayload(value)) {
|
|
18
|
-
return value;
|
|
19
|
-
}
|
|
20
|
-
return void 0;
|
|
21
|
-
}
|
|
22
|
-
function resolveDedupeKey(options, context) {
|
|
23
|
-
return typeof options.dedupeKey === "function" ? options.dedupeKey(context) : options.dedupeKey;
|
|
24
|
-
}
|
|
25
|
-
function resolveMetadata(options, context) {
|
|
26
|
-
return typeof options.metadata === "function" ? options.metadata(context) : options.metadata;
|
|
27
|
-
}
|
|
28
|
-
function normalizeFragment(resolved, options, context) {
|
|
29
|
-
const payload = typeof resolved === "string" ? { content: resolved } : isPayload(resolved) ? resolved : void 0;
|
|
30
|
-
if (!payload) {
|
|
31
|
-
return resolved;
|
|
32
|
-
}
|
|
33
|
-
if (payload.content.trim().length === 0) {
|
|
34
|
-
return void 0;
|
|
35
|
-
}
|
|
36
|
-
const dedupeKey = payload.dedupeKey ?? resolveDedupeKey(options, context);
|
|
37
|
-
const metadata = payload.metadata ?? resolveMetadata(options, context);
|
|
38
|
-
const maxChars = payload.maxChars ?? options.maxChars;
|
|
39
|
-
return {
|
|
40
|
-
kind: payload.kind ?? options.kind ?? "slack-context",
|
|
41
|
-
content: payload.content,
|
|
42
|
-
role: payload.role ?? options.role ?? "user",
|
|
43
|
-
placement: payload.placement ?? options.placement ?? "after-latest-user",
|
|
44
|
-
lifetime: payload.lifetime ?? options.lifetime ?? "turn",
|
|
45
|
-
source: payload.source ?? options.source ?? "slack",
|
|
46
|
-
title: payload.title ?? options.title ?? "Slack Context",
|
|
47
|
-
budgetBehavior: payload.budgetBehavior ?? options.budgetBehavior ?? "droppable",
|
|
48
|
-
...maxChars !== void 0 ? { maxChars } : {},
|
|
49
|
-
...dedupeKey ? { dedupeKey } : {},
|
|
50
|
-
...metadata ? { metadata } : {}
|
|
51
|
-
};
|
|
52
|
-
}
|
|
53
|
-
function createSlackContextFragmentMiddleware(options = {}) {
|
|
54
|
-
const contextKey = options.contextKey ?? DEFAULT_SLACK_CONTEXT_FRAGMENT_KEY;
|
|
55
|
-
return {
|
|
56
|
-
name: options.name ?? "slack-context-fragment",
|
|
57
|
-
async contextFragments(step) {
|
|
58
|
-
const slack = currentSlackTurnContext();
|
|
59
|
-
if (!slack) {
|
|
60
|
-
return void 0;
|
|
61
|
-
}
|
|
62
|
-
const context = { slack, step };
|
|
63
|
-
const resolved = options.resolve ? await options.resolve(context) : resolveContextBagValue(slack, contextKey);
|
|
64
|
-
if (resolved === void 0) {
|
|
65
|
-
return void 0;
|
|
66
|
-
}
|
|
67
|
-
return normalizeFragment(resolved, options, context);
|
|
68
|
-
}
|
|
69
|
-
};
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
export {
|
|
73
|
-
DEFAULT_SLACK_CONTEXT_FRAGMENT_KEY,
|
|
74
|
-
createSlackContextFragmentMiddleware
|
|
75
|
-
};
|
package/dist/chunk-C7CHMYV6.js
DELETED
|
@@ -1,226 +0,0 @@
|
|
|
1
|
-
// src/views/controller.ts
|
|
2
|
-
import { registerSlackViewWorkflow } from "@cuylabs/channel-slack/views";
|
|
3
|
-
|
|
4
|
-
// src/views/state.ts
|
|
5
|
-
function extractSlackAgentViewStateValues(viewOrState) {
|
|
6
|
-
const state = isRecord(viewOrState) ? isRecord(viewOrState.state) ? viewOrState.state : viewOrState : {};
|
|
7
|
-
const rawValues = isRecord(state.values) ? state.values : {};
|
|
8
|
-
const values = {};
|
|
9
|
-
for (const [blockId, rawActions] of Object.entries(rawValues)) {
|
|
10
|
-
if (!isRecord(rawActions)) {
|
|
11
|
-
continue;
|
|
12
|
-
}
|
|
13
|
-
const actions = {};
|
|
14
|
-
for (const [actionId, rawAction] of Object.entries(rawActions)) {
|
|
15
|
-
actions[actionId] = extractSlackAgentViewActionValue(rawAction);
|
|
16
|
-
}
|
|
17
|
-
values[blockId] = actions;
|
|
18
|
-
}
|
|
19
|
-
return values;
|
|
20
|
-
}
|
|
21
|
-
function readSlackAgentViewStateValue(valuesOrView, blockId, actionId) {
|
|
22
|
-
const values = looksLikeExtractedStateValues(valuesOrView) ? valuesOrView : extractSlackAgentViewStateValues(valuesOrView);
|
|
23
|
-
return values[blockId]?.[actionId];
|
|
24
|
-
}
|
|
25
|
-
function extractSlackAgentViewActionValue(rawAction) {
|
|
26
|
-
if (!isRecord(rawAction)) {
|
|
27
|
-
return void 0;
|
|
28
|
-
}
|
|
29
|
-
if ("value" in rawAction && typeof rawAction.value !== "undefined") {
|
|
30
|
-
return normalizeValue(rawAction.value);
|
|
31
|
-
}
|
|
32
|
-
if (isRecord(rawAction.selected_option)) {
|
|
33
|
-
return readOptionValue(rawAction.selected_option);
|
|
34
|
-
}
|
|
35
|
-
if (Array.isArray(rawAction.selected_options)) {
|
|
36
|
-
return rawAction.selected_options.map(readOptionValue).filter(isString);
|
|
37
|
-
}
|
|
38
|
-
for (const field of [
|
|
39
|
-
"selected_user",
|
|
40
|
-
"selected_users",
|
|
41
|
-
"selected_channel",
|
|
42
|
-
"selected_channels",
|
|
43
|
-
"selected_conversation",
|
|
44
|
-
"selected_conversations",
|
|
45
|
-
"selected_date",
|
|
46
|
-
"selected_time",
|
|
47
|
-
"selected_date_time"
|
|
48
|
-
]) {
|
|
49
|
-
const value = rawAction[field];
|
|
50
|
-
if (typeof value !== "undefined") {
|
|
51
|
-
return normalizeValue(value);
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
if (typeof rawAction.checked === "boolean") {
|
|
55
|
-
return rawAction.checked;
|
|
56
|
-
}
|
|
57
|
-
return rawAction;
|
|
58
|
-
}
|
|
59
|
-
function readOptionValue(option) {
|
|
60
|
-
if (!isRecord(option)) {
|
|
61
|
-
return "";
|
|
62
|
-
}
|
|
63
|
-
if (typeof option.value === "string") {
|
|
64
|
-
return option.value;
|
|
65
|
-
}
|
|
66
|
-
const text = option.text;
|
|
67
|
-
if (isRecord(text) && typeof text.text === "string") {
|
|
68
|
-
return text.text;
|
|
69
|
-
}
|
|
70
|
-
return "";
|
|
71
|
-
}
|
|
72
|
-
function normalizeValue(value) {
|
|
73
|
-
if (typeof value === "string" || typeof value === "boolean" || typeof value === "number") {
|
|
74
|
-
return value;
|
|
75
|
-
}
|
|
76
|
-
if (Array.isArray(value)) {
|
|
77
|
-
return value.filter(isString);
|
|
78
|
-
}
|
|
79
|
-
return isRecord(value) ? value : void 0;
|
|
80
|
-
}
|
|
81
|
-
function looksLikeExtractedStateValues(value) {
|
|
82
|
-
if (!isRecord(value) || "state" in value || "values" in value) {
|
|
83
|
-
return false;
|
|
84
|
-
}
|
|
85
|
-
return Object.values(value).every(isRecord);
|
|
86
|
-
}
|
|
87
|
-
function isRecord(value) {
|
|
88
|
-
return typeof value === "object" && value !== null;
|
|
89
|
-
}
|
|
90
|
-
function isString(value) {
|
|
91
|
-
return typeof value === "string";
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
// src/views/controller.ts
|
|
95
|
-
var DEFAULT_NAMESPACE = "agent_slack_view";
|
|
96
|
-
var installedCallbackIds = /* @__PURE__ */ new WeakMap();
|
|
97
|
-
function createSlackAgentViewWorkflowController({
|
|
98
|
-
namespace = DEFAULT_NAMESPACE,
|
|
99
|
-
workflows = [],
|
|
100
|
-
onError
|
|
101
|
-
} = {}) {
|
|
102
|
-
const normalizedNamespace = normalizeIdentifier(namespace, "namespace");
|
|
103
|
-
const registeredWorkflows = /* @__PURE__ */ new Map();
|
|
104
|
-
const installedApps = /* @__PURE__ */ new Set();
|
|
105
|
-
function register(workflow) {
|
|
106
|
-
const workflowId = normalizeIdentifier(workflow.id, "workflow id");
|
|
107
|
-
if (!workflow.onSubmission && !workflow.onClose) {
|
|
108
|
-
throw new Error(
|
|
109
|
-
`Slack agent view workflow '${workflowId}' must define onSubmission or onClose.`
|
|
110
|
-
);
|
|
111
|
-
}
|
|
112
|
-
if (registeredWorkflows.has(workflowId)) {
|
|
113
|
-
throw new Error(`Duplicate Slack agent view workflow id: ${workflowId}`);
|
|
114
|
-
}
|
|
115
|
-
const callbackId = normalizeOptionalIdentifier(workflow.callbackId) ?? callbackIdFromWorkflowId(normalizedNamespace, workflowId);
|
|
116
|
-
if ([...registeredWorkflows.values()].some(
|
|
117
|
-
(item) => item.callbackId === callbackId
|
|
118
|
-
)) {
|
|
119
|
-
throw new Error(`Duplicate Slack view callback id: ${callbackId}`);
|
|
120
|
-
}
|
|
121
|
-
const registered = {
|
|
122
|
-
...workflow,
|
|
123
|
-
id: workflowId,
|
|
124
|
-
callbackId
|
|
125
|
-
};
|
|
126
|
-
registeredWorkflows.set(workflowId, registered);
|
|
127
|
-
for (const app of installedApps) {
|
|
128
|
-
installWorkflow(app, registered);
|
|
129
|
-
}
|
|
130
|
-
return callbackId;
|
|
131
|
-
}
|
|
132
|
-
function callbackIdFor(workflowId) {
|
|
133
|
-
const normalizedWorkflowId = normalizeIdentifier(workflowId, "workflow id");
|
|
134
|
-
return registeredWorkflows.get(normalizedWorkflowId)?.callbackId ?? callbackIdFromWorkflowId(normalizedNamespace, normalizedWorkflowId);
|
|
135
|
-
}
|
|
136
|
-
function list() {
|
|
137
|
-
return [...registeredWorkflows.values()].map(({ id, callbackId }) => ({
|
|
138
|
-
id,
|
|
139
|
-
callbackId
|
|
140
|
-
}));
|
|
141
|
-
}
|
|
142
|
-
function install(app) {
|
|
143
|
-
installedApps.add(app);
|
|
144
|
-
for (const workflow of registeredWorkflows.values()) {
|
|
145
|
-
installWorkflow(app, workflow);
|
|
146
|
-
}
|
|
147
|
-
}
|
|
148
|
-
function installWorkflow(app, workflow) {
|
|
149
|
-
const callbackIds = callbackIdsForApp(app);
|
|
150
|
-
if (callbackIds.has(workflow.callbackId)) {
|
|
151
|
-
throw new Error(
|
|
152
|
-
`Slack view callback id '${workflow.callbackId}' is already installed on this Bolt app.`
|
|
153
|
-
);
|
|
154
|
-
}
|
|
155
|
-
callbackIds.add(workflow.callbackId);
|
|
156
|
-
registerSlackViewWorkflow({
|
|
157
|
-
boltApp: app,
|
|
158
|
-
callbackId: workflow.callbackId,
|
|
159
|
-
...workflow.decodePrivateMetadata ? { decodePrivateMetadata: workflow.decodePrivateMetadata } : {},
|
|
160
|
-
...workflow.onSubmission ? {
|
|
161
|
-
onSubmission: async (context) => await workflow.onSubmission(enrichContext(workflow, context))
|
|
162
|
-
} : {},
|
|
163
|
-
...workflow.onClose ? {
|
|
164
|
-
onClose: async (context) => await workflow.onClose(enrichContext(workflow, context))
|
|
165
|
-
} : {},
|
|
166
|
-
onError: async (error, context) => {
|
|
167
|
-
const enriched = enrichContext(workflow, {
|
|
168
|
-
...context,
|
|
169
|
-
metadata: context.metadata
|
|
170
|
-
});
|
|
171
|
-
if (workflow.onError) {
|
|
172
|
-
await workflow.onError(error, enriched);
|
|
173
|
-
return;
|
|
174
|
-
}
|
|
175
|
-
await onError?.(error, enriched);
|
|
176
|
-
}
|
|
177
|
-
});
|
|
178
|
-
}
|
|
179
|
-
for (const workflow of workflows) {
|
|
180
|
-
register(workflow);
|
|
181
|
-
}
|
|
182
|
-
return {
|
|
183
|
-
namespace: normalizedNamespace,
|
|
184
|
-
register,
|
|
185
|
-
callbackIdFor,
|
|
186
|
-
list,
|
|
187
|
-
install
|
|
188
|
-
};
|
|
189
|
-
}
|
|
190
|
-
function enrichContext(workflow, context) {
|
|
191
|
-
const stateValues = extractSlackAgentViewStateValues(context.view);
|
|
192
|
-
return {
|
|
193
|
-
...context,
|
|
194
|
-
workflow: { id: workflow.id, callbackId: workflow.callbackId },
|
|
195
|
-
stateValues,
|
|
196
|
-
getStateValue: (blockId, actionId) => readSlackAgentViewStateValue(stateValues, blockId, actionId)
|
|
197
|
-
};
|
|
198
|
-
}
|
|
199
|
-
function callbackIdsForApp(app) {
|
|
200
|
-
let callbackIds = installedCallbackIds.get(app);
|
|
201
|
-
if (!callbackIds) {
|
|
202
|
-
callbackIds = /* @__PURE__ */ new Set();
|
|
203
|
-
installedCallbackIds.set(app, callbackIds);
|
|
204
|
-
}
|
|
205
|
-
return callbackIds;
|
|
206
|
-
}
|
|
207
|
-
function callbackIdFromWorkflowId(namespace, workflowId) {
|
|
208
|
-
return `${namespace}_${workflowId}`;
|
|
209
|
-
}
|
|
210
|
-
function normalizeOptionalIdentifier(value) {
|
|
211
|
-
const normalized = value?.trim();
|
|
212
|
-
return normalized ? normalized : void 0;
|
|
213
|
-
}
|
|
214
|
-
function normalizeIdentifier(value, label) {
|
|
215
|
-
const normalized = value.trim().replace(/[^A-Za-z0-9_-]+/g, "_").replace(/^_+|_+$/g, "");
|
|
216
|
-
if (!normalized) {
|
|
217
|
-
throw new Error(`Slack agent view workflow ${label} cannot be empty.`);
|
|
218
|
-
}
|
|
219
|
-
return normalized;
|
|
220
|
-
}
|
|
221
|
-
|
|
222
|
-
export {
|
|
223
|
-
extractSlackAgentViewStateValues,
|
|
224
|
-
readSlackAgentViewStateValue,
|
|
225
|
-
createSlackAgentViewWorkflowController
|
|
226
|
-
};
|
package/dist/chunk-D4CSEAIF.js
DELETED
|
@@ -1,82 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
createSlackChannelAdapter
|
|
3
|
-
} from "./chunk-XA7U3GRN.js";
|
|
4
|
-
|
|
5
|
-
// src/express.ts
|
|
6
|
-
import {
|
|
7
|
-
createSlackBoltApp
|
|
8
|
-
} from "@cuylabs/channel-slack/transports/http";
|
|
9
|
-
async function mountSlackAgent(source, options = {}) {
|
|
10
|
-
const {
|
|
11
|
-
botToken: providedToken,
|
|
12
|
-
signingSecret,
|
|
13
|
-
auth,
|
|
14
|
-
path,
|
|
15
|
-
processBeforeResponse,
|
|
16
|
-
signatureVerification,
|
|
17
|
-
boltAppOptions,
|
|
18
|
-
receiverOptions,
|
|
19
|
-
port: portOption,
|
|
20
|
-
host,
|
|
21
|
-
app: providedApp,
|
|
22
|
-
...adapterOptions
|
|
23
|
-
} = options;
|
|
24
|
-
const {
|
|
25
|
-
boltApp,
|
|
26
|
-
receiver,
|
|
27
|
-
app: expressApp,
|
|
28
|
-
authMode,
|
|
29
|
-
routePath
|
|
30
|
-
} = await createSlackBoltApp({
|
|
31
|
-
signingSecret,
|
|
32
|
-
path,
|
|
33
|
-
botToken: providedToken,
|
|
34
|
-
auth,
|
|
35
|
-
app: providedApp,
|
|
36
|
-
processBeforeResponse,
|
|
37
|
-
signatureVerification,
|
|
38
|
-
boltAppOptions,
|
|
39
|
-
receiverOptions
|
|
40
|
-
});
|
|
41
|
-
const channelAdapter = createSlackChannelAdapter({
|
|
42
|
-
source,
|
|
43
|
-
...adapterOptions
|
|
44
|
-
});
|
|
45
|
-
channelAdapter.mount(boltApp);
|
|
46
|
-
mountReceiverRouter(expressApp, receiver);
|
|
47
|
-
const port = portOption === void 0 ? resolvePort(process.env.PORT) : portOption;
|
|
48
|
-
let server;
|
|
49
|
-
if (!providedApp && port !== null) {
|
|
50
|
-
const onListen = () => {
|
|
51
|
-
process.stdout.write(
|
|
52
|
-
`Slack bot listening on port ${port} at ${routePath}
|
|
53
|
-
`
|
|
54
|
-
);
|
|
55
|
-
};
|
|
56
|
-
server = host ? expressApp.listen(port, host, onListen) : expressApp.listen(port, onListen);
|
|
57
|
-
}
|
|
58
|
-
return {
|
|
59
|
-
app: expressApp,
|
|
60
|
-
boltApp,
|
|
61
|
-
receiver,
|
|
62
|
-
authMode,
|
|
63
|
-
routePath,
|
|
64
|
-
channelAdapter,
|
|
65
|
-
server
|
|
66
|
-
};
|
|
67
|
-
}
|
|
68
|
-
function resolvePort(port) {
|
|
69
|
-
if (!port) return 3e3;
|
|
70
|
-
const parsed = Number(port);
|
|
71
|
-
if (!Number.isInteger(parsed) || parsed < 0) {
|
|
72
|
-
throw new Error(`Invalid PORT value: ${port}`);
|
|
73
|
-
}
|
|
74
|
-
return parsed;
|
|
75
|
-
}
|
|
76
|
-
function mountReceiverRouter(app, receiver) {
|
|
77
|
-
app.use(receiver.router);
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
export {
|
|
81
|
-
mountSlackAgent
|
|
82
|
-
};
|
package/dist/chunk-ELR6MQD7.js
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
// src/feedback/index.ts
|
|
2
|
-
import {
|
|
3
|
-
SLACK_FEEDBACK_ACTION_ID,
|
|
4
|
-
createSlackFeedbackBlock,
|
|
5
|
-
registerSlackFeedbackAction
|
|
6
|
-
} from "@cuylabs/channel-slack/feedback";
|
|
7
|
-
|
|
8
|
-
export {
|
|
9
|
-
SLACK_FEEDBACK_ACTION_ID,
|
|
10
|
-
createSlackFeedbackBlock,
|
|
11
|
-
registerSlackFeedbackAction
|
|
12
|
-
};
|