@openclaw/slack 2026.5.27 → 2026.5.28-beta.1
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/dist/{account-inspect-vVg3pT03.js → account-inspect-CdGk6R7l.js} +1 -1
- package/dist/account-inspect-api.js +1 -1
- package/dist/{accounts-BnLQ3fe2.js → accounts-f6Xcv9Vi.js} +42 -1
- package/dist/accounts.runtime-BJt1IxOS.js +2 -0
- package/dist/{action-runtime-JVb7KyQs.js → action-runtime-BOEgcnv6.js} +7 -8
- package/dist/action-runtime.runtime-BXQYV0yA.js +2 -0
- package/dist/{actions-1o9nMIY8.js → actions-zfVWcIY6.js} +4 -4
- package/dist/{actions.runtime-qQtdNww-.js → actions.runtime-CoijPN8g.js} +1 -1
- package/dist/api.js +14 -17
- package/dist/{approval-handler.runtime-Ba8nwnYi.js → approval-handler.runtime-CWz3XLfN.js} +12 -69
- package/dist/{channel-Bd7eept6.js → channel-B9uavFQM.js} +25 -28
- package/dist/channel-config-api.js +1 -1
- package/dist/channel-plugin-api.js +1 -1
- package/dist/{channel.setup-WNNVmCm0.js → channel.setup-oGp4gSTP.js} +4 -4
- package/dist/{client-Dc2Ji2YN.js → client-DowBk5k0.js} +6 -24
- package/dist/{config-schema-CUiDK8HV.js → config-schema-C0RewpJQ.js} +4 -0
- package/dist/contract-api.js +1 -1
- package/dist/{directory-config-9_djLTOK.js → directory-config-8UPAEyNg.js} +1 -1
- package/dist/directory-contract-api.js +1 -1
- package/dist/{directory-live-Cl83cGLZ.js → directory-live-BFB1pSax.js} +2 -2
- package/dist/http-routes-api.js +1 -1
- package/dist/index.js +3 -7
- package/dist/{interactive-replies-DtYu4Sf5.js → interactive-replies-DrBq4Mld.js} +1 -1
- package/dist/interactive-replies-api.js +1 -1
- package/dist/{message-tool-api-BieXX5lk.js → message-tool-api-B9M0zzlQ.js} +2 -2
- package/dist/message-tool-api.js +1 -1
- package/dist/{monitor-Cn7LUDFL.js → monitor-BzzGqB63.js} +3 -4
- package/dist/{outbound-adapter-ChuR4_0v.js → outbound-adapter-BHZMgblN.js} +4 -7
- package/dist/{prepare-Bl5WcC3f.js → pipeline.runtime-XK36f1W3.js} +1769 -47
- package/dist/plugin-routes-B9PvcDQJ.js +22 -0
- package/dist/{policy-pu8tsF8_.js → policy-BBDU-PQK.js} +1 -1
- package/dist/{probe-cBVPhCKZ.js → probe-Djes9Fy6.js} +1 -1
- package/dist/{provider-Bccng2Wp.js → provider-CfZypaNV.js} +826 -26
- package/dist/{replies-jiEDV6lH.js → replies-DkmWK7JW.js} +2 -4
- package/dist/{resolve-channels-CT4oiz_9.js → resolve-channels-zXt5f47h.js} +1 -1
- package/dist/{resolve-users-o5S-Ijks.js → resolve-users-BLfGAz1v.js} +1 -1
- package/dist/{runtime-api-CyPE-EvY.js → runtime-api-DvpUD2hw.js} +2 -2
- package/dist/runtime-api.js +12 -12
- package/dist/{scopes-CnyhLIPT.js → scopes-DiiHsqh1.js} +1 -1
- package/dist/{send-DvfE8LVm.js → send-BURYyCXI.js} +4 -4
- package/dist/send.runtime-CKaMG3s-.js +2 -0
- package/dist/{setup-core-DKe7Ug3V.js → setup-core-POfI_bgP.js} +2 -2
- package/dist/setup-entry.js +8 -1
- package/dist/setup-plugin-api.js +1 -1
- package/dist/{setup-surface-gjRthuZA.js → setup-surface-DJTHAguz.js} +5 -5
- package/dist/{shared-D8A7iVVH.js → shared-D9WMYymo.js} +5 -5
- package/dist/{slash-dispatch.runtime-BBhdJHb8.js → slash-dispatch.runtime-lsyTm_q5.js} +1 -1
- package/dist/thread-ts-NSVqWybn.js +646 -0
- package/node_modules/semver/classes/range.js +7 -0
- package/node_modules/semver/package.json +1 -1
- package/node_modules/semver/ranges/subset.js +2 -2
- package/npm-shrinkwrap.json +6 -29
- package/openclaw.plugin.json +10 -0
- package/package.json +8 -7
- package/dist/accounts.runtime-BVdtQeuq.js +0 -2
- package/dist/action-runtime.runtime-BZa5VDjs.js +0 -2
- package/dist/allow-list-B1lkGjwl.js +0 -82
- package/dist/blocks-render-CNC4vQnd.js +0 -232
- package/dist/inbound-contract-test-api.js +0 -3
- package/dist/magic-string.es-BPXBBMwL.js +0 -1011
- package/dist/outbound-payload-test-api.js +0 -2
- package/dist/outbound-payload.test-harness-8MnHFgR1.js +0 -13551
- package/dist/pipeline.runtime-BVK8yXw_.js +0 -1473
- package/dist/plugin-routes-DRR3ijKM.js +0 -20
- package/dist/prepare.test-helpers-BcAo4KMw.js +0 -49
- package/dist/reply-blocks-BlOURkUm.js +0 -290
- package/dist/room-context-BmNTBiw5.js +0 -816
- package/dist/send.runtime-Dv6ajTGK.js +0 -2
- package/dist/send.runtime-v3TSw9xY.js +0 -2
- package/dist/test-api.js +0 -8
- package/dist/thread-ts-ks-O8cEG.js +0 -52
- package/node_modules/agent-base/LICENSE +0 -22
- package/node_modules/agent-base/README.md +0 -69
- package/node_modules/agent-base/dist/helpers.d.ts +0 -10
- package/node_modules/agent-base/dist/helpers.d.ts.map +0 -1
- package/node_modules/agent-base/dist/helpers.js +0 -37
- package/node_modules/agent-base/dist/helpers.js.map +0 -1
- package/node_modules/agent-base/dist/index.d.ts +0 -37
- package/node_modules/agent-base/dist/index.d.ts.map +0 -1
- package/node_modules/agent-base/dist/index.js +0 -146
- package/node_modules/agent-base/dist/index.js.map +0 -1
- package/node_modules/agent-base/package.json +0 -46
- package/node_modules/https-proxy-agent/LICENSE +0 -22
- package/node_modules/https-proxy-agent/README.md +0 -70
- package/node_modules/https-proxy-agent/dist/index.d.ts +0 -43
- package/node_modules/https-proxy-agent/dist/index.d.ts.map +0 -1
- package/node_modules/https-proxy-agent/dist/index.js +0 -150
- package/node_modules/https-proxy-agent/dist/index.js.map +0 -1
- package/node_modules/https-proxy-agent/dist/parse-proxy-response.d.ts +0 -12
- package/node_modules/https-proxy-agent/dist/parse-proxy-response.d.ts.map +0 -1
- package/node_modules/https-proxy-agent/dist/parse-proxy-response.js +0 -94
- package/node_modules/https-proxy-agent/dist/parse-proxy-response.js.map +0 -1
- package/node_modules/https-proxy-agent/package.json +0 -50
package/npm-shrinkwrap.json
CHANGED
|
@@ -1,22 +1,21 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@openclaw/slack",
|
|
3
|
-
"version": "2026.5.
|
|
3
|
+
"version": "2026.5.28-beta.1",
|
|
4
4
|
"lockfileVersion": 3,
|
|
5
5
|
"requires": true,
|
|
6
6
|
"packages": {
|
|
7
7
|
"": {
|
|
8
8
|
"name": "@openclaw/slack",
|
|
9
|
-
"version": "2026.5.
|
|
9
|
+
"version": "2026.5.28-beta.1",
|
|
10
10
|
"dependencies": {
|
|
11
11
|
"@slack/bolt": "4.7.2",
|
|
12
12
|
"@slack/types": "2.21.1",
|
|
13
13
|
"@slack/web-api": "7.16.0",
|
|
14
|
-
"https-proxy-agent": "9.0.0",
|
|
15
14
|
"typebox": "1.1.38",
|
|
16
15
|
"zod": "4.4.3"
|
|
17
16
|
},
|
|
18
17
|
"peerDependencies": {
|
|
19
|
-
"openclaw": ">=2026.5.
|
|
18
|
+
"openclaw": ">=2026.5.28-beta.1"
|
|
20
19
|
},
|
|
21
20
|
"peerDependenciesMeta": {
|
|
22
21
|
"openclaw": {
|
|
@@ -263,15 +262,6 @@
|
|
|
263
262
|
"node": ">= 0.6"
|
|
264
263
|
}
|
|
265
264
|
},
|
|
266
|
-
"node_modules/agent-base": {
|
|
267
|
-
"version": "9.0.0",
|
|
268
|
-
"resolved": "https://registry.npmjs.org/agent-base/-/agent-base-9.0.0.tgz",
|
|
269
|
-
"integrity": "sha512-TQf59BsZnytt8GdJKLPfUZ54g/iaUL2OWDSFCCvMOhsHduDQxO8xC4PNeyIkVcA5KwL2phPSv0douC0fgWzmnA==",
|
|
270
|
-
"license": "MIT",
|
|
271
|
-
"engines": {
|
|
272
|
-
"node": ">= 20"
|
|
273
|
-
}
|
|
274
|
-
},
|
|
275
265
|
"node_modules/asynckit": {
|
|
276
266
|
"version": "0.4.0",
|
|
277
267
|
"resolved": "https://registry.npmjs.org/asynckit/-/asynckit-0.4.0.tgz",
|
|
@@ -813,19 +803,6 @@
|
|
|
813
803
|
"url": "https://opencollective.com/express"
|
|
814
804
|
}
|
|
815
805
|
},
|
|
816
|
-
"node_modules/https-proxy-agent": {
|
|
817
|
-
"version": "9.0.0",
|
|
818
|
-
"resolved": "https://registry.npmjs.org/https-proxy-agent/-/https-proxy-agent-9.0.0.tgz",
|
|
819
|
-
"integrity": "sha512-/MVmHp58WkOypgFhCLk4fzpPcFQvTJ/e6LBI7irpIO2HfxUbpmYoHF+KzipzJpxxzJu7aJNWQ0xojJ/dzV2G5g==",
|
|
820
|
-
"license": "MIT",
|
|
821
|
-
"dependencies": {
|
|
822
|
-
"agent-base": "9.0.0",
|
|
823
|
-
"debug": "^4.3.4"
|
|
824
|
-
},
|
|
825
|
-
"engines": {
|
|
826
|
-
"node": ">= 20"
|
|
827
|
-
}
|
|
828
|
-
},
|
|
829
806
|
"node_modules/iconv-lite": {
|
|
830
807
|
"version": "0.7.2",
|
|
831
808
|
"resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.7.2.tgz",
|
|
@@ -1257,9 +1234,9 @@
|
|
|
1257
1234
|
"license": "MIT"
|
|
1258
1235
|
},
|
|
1259
1236
|
"node_modules/semver": {
|
|
1260
|
-
"version": "7.8.
|
|
1261
|
-
"resolved": "https://registry.npmjs.org/semver/-/semver-7.8.
|
|
1262
|
-
"integrity": "sha512-
|
|
1237
|
+
"version": "7.8.1",
|
|
1238
|
+
"resolved": "https://registry.npmjs.org/semver/-/semver-7.8.1.tgz",
|
|
1239
|
+
"integrity": "sha512-rkVq3IXh+4FDGch+KwzX3aV9W3kO54GyEgpvBzSyctDA6Xtd7RJQV1xmXbeQp5v7+VzLOfVqiutSE6GICgPFvg==",
|
|
1263
1240
|
"license": "ISC",
|
|
1264
1241
|
"bin": {
|
|
1265
1242
|
"semver": "bin/semver.js"
|
package/openclaw.plugin.json
CHANGED
|
@@ -703,6 +703,9 @@
|
|
|
703
703
|
"raw",
|
|
704
704
|
"status"
|
|
705
705
|
]
|
|
706
|
+
},
|
|
707
|
+
"nativeTaskCards": {
|
|
708
|
+
"type": "boolean"
|
|
706
709
|
}
|
|
707
710
|
},
|
|
708
711
|
"additionalProperties": false
|
|
@@ -1863,6 +1866,9 @@
|
|
|
1863
1866
|
"raw",
|
|
1864
1867
|
"status"
|
|
1865
1868
|
]
|
|
1869
|
+
},
|
|
1870
|
+
"nativeTaskCards": {
|
|
1871
|
+
"type": "boolean"
|
|
1866
1872
|
}
|
|
1867
1873
|
},
|
|
1868
1874
|
"additionalProperties": false
|
|
@@ -2523,6 +2529,10 @@
|
|
|
2523
2529
|
"label": "Slack Progress Renderer",
|
|
2524
2530
|
"help": "Progress draft renderer: \"text\" uses one portable text body; \"rich\" renders structured Slack Block Kit fields with the same text fallback."
|
|
2525
2531
|
},
|
|
2532
|
+
"streaming.progress.nativeTaskCards": {
|
|
2533
|
+
"label": "Slack Native Progress Task Cards",
|
|
2534
|
+
"help": "Opt in to Slack native task-card progress updates when channels.slack.streaming.mode=\"progress\" and streaming.nativeTransport is enabled. Default: false."
|
|
2535
|
+
},
|
|
2526
2536
|
"streaming.progress.toolProgress": {
|
|
2527
2537
|
"label": "Slack Progress Tool Lines",
|
|
2528
2538
|
"help": "Show compact tool/progress lines in progress draft mode (default: true). Set false to keep only the label until final delivery."
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@openclaw/slack",
|
|
3
|
-
"version": "2026.5.
|
|
3
|
+
"version": "2026.5.28-beta.1",
|
|
4
4
|
"description": "OpenClaw Slack channel plugin for channels, DMs, commands, and app events.",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -11,12 +11,11 @@
|
|
|
11
11
|
"@slack/bolt": "4.7.2",
|
|
12
12
|
"@slack/types": "2.21.1",
|
|
13
13
|
"@slack/web-api": "7.16.0",
|
|
14
|
-
"https-proxy-agent": "9.0.0",
|
|
15
14
|
"typebox": "1.1.38",
|
|
16
15
|
"zod": "4.4.3"
|
|
17
16
|
},
|
|
18
17
|
"peerDependencies": {
|
|
19
|
-
"openclaw": ">=2026.5.
|
|
18
|
+
"openclaw": ">=2026.5.28-beta.1"
|
|
20
19
|
},
|
|
21
20
|
"peerDependenciesMeta": {
|
|
22
21
|
"openclaw": {
|
|
@@ -57,14 +56,17 @@
|
|
|
57
56
|
"install": {
|
|
58
57
|
"npmSpec": "@openclaw/slack",
|
|
59
58
|
"defaultChoice": "npm",
|
|
60
|
-
"minHostVersion": ">=2026.5.
|
|
59
|
+
"minHostVersion": ">=2026.5.28",
|
|
61
60
|
"allowInvalidConfigRecovery": true
|
|
62
61
|
},
|
|
63
62
|
"compat": {
|
|
64
|
-
"pluginApi": ">=2026.5.
|
|
63
|
+
"pluginApi": ">=2026.5.28-beta.1"
|
|
64
|
+
},
|
|
65
|
+
"startup": {
|
|
66
|
+
"deferConfiguredChannelFullLoadUntilAfterListen": true
|
|
65
67
|
},
|
|
66
68
|
"build": {
|
|
67
|
-
"openclawVersion": "2026.5.
|
|
69
|
+
"openclawVersion": "2026.5.28-beta.1",
|
|
68
70
|
"bundledDist": false
|
|
69
71
|
},
|
|
70
72
|
"release": {
|
|
@@ -85,7 +87,6 @@
|
|
|
85
87
|
"@slack/bolt",
|
|
86
88
|
"@slack/types",
|
|
87
89
|
"@slack/web-api",
|
|
88
|
-
"https-proxy-agent",
|
|
89
90
|
"typebox",
|
|
90
91
|
"zod"
|
|
91
92
|
]
|
|
@@ -1,82 +0,0 @@
|
|
|
1
|
-
import { normalizeOptionalLowercaseString } from "openclaw/plugin-sdk/string-coerce-runtime";
|
|
2
|
-
import { compileAllowlist, resolveCompiledAllowlistMatch } from "openclaw/plugin-sdk/allow-from";
|
|
3
|
-
import { normalizeHyphenSlug, normalizeStringEntries as normalizeStringEntries$1, normalizeStringEntriesLower as normalizeStringEntriesLower$1 } from "openclaw/plugin-sdk/string-normalization-runtime";
|
|
4
|
-
//#region extensions/slack/src/monitor/allow-list.ts
|
|
5
|
-
const SLACK_SLUG_CACHE_MAX = 512;
|
|
6
|
-
const slackSlugCache = /* @__PURE__ */ new Map();
|
|
7
|
-
function normalizeSlackSlug(raw) {
|
|
8
|
-
const key = raw ?? "";
|
|
9
|
-
const cached = slackSlugCache.get(key);
|
|
10
|
-
if (cached !== void 0) return cached;
|
|
11
|
-
const normalized = normalizeHyphenSlug(raw);
|
|
12
|
-
slackSlugCache.set(key, normalized);
|
|
13
|
-
if (slackSlugCache.size > SLACK_SLUG_CACHE_MAX) {
|
|
14
|
-
const oldest = slackSlugCache.keys().next();
|
|
15
|
-
if (!oldest.done) slackSlugCache.delete(oldest.value);
|
|
16
|
-
}
|
|
17
|
-
return normalized;
|
|
18
|
-
}
|
|
19
|
-
function normalizeAllowList(list) {
|
|
20
|
-
return normalizeStringEntries$1(list);
|
|
21
|
-
}
|
|
22
|
-
function normalizeAllowListLower(list) {
|
|
23
|
-
return normalizeStringEntriesLower$1(list);
|
|
24
|
-
}
|
|
25
|
-
function normalizeSlackAllowOwnerEntry(entry) {
|
|
26
|
-
const trimmed = normalizeOptionalLowercaseString(entry);
|
|
27
|
-
if (!trimmed || trimmed === "*") return;
|
|
28
|
-
const withoutPrefix = trimmed.replace(/^(slack:|user:)/, "");
|
|
29
|
-
return /^u[a-z0-9]+$/.test(withoutPrefix) ? withoutPrefix : void 0;
|
|
30
|
-
}
|
|
31
|
-
function resolveSlackAllowListMatch(params) {
|
|
32
|
-
const compiledAllowList = compileAllowlist(params.allowList);
|
|
33
|
-
const id = normalizeOptionalLowercaseString(params.id);
|
|
34
|
-
const name = normalizeOptionalLowercaseString(params.name);
|
|
35
|
-
const slug = normalizeSlackSlug(name);
|
|
36
|
-
return resolveCompiledAllowlistMatch({
|
|
37
|
-
compiledAllowlist: compiledAllowList,
|
|
38
|
-
candidates: [
|
|
39
|
-
{
|
|
40
|
-
value: id,
|
|
41
|
-
source: "id"
|
|
42
|
-
},
|
|
43
|
-
{
|
|
44
|
-
value: id ? `slack:${id}` : void 0,
|
|
45
|
-
source: "prefixed-id"
|
|
46
|
-
},
|
|
47
|
-
{
|
|
48
|
-
value: id ? `user:${id}` : void 0,
|
|
49
|
-
source: "prefixed-user"
|
|
50
|
-
},
|
|
51
|
-
...params.allowNameMatching === true ? [
|
|
52
|
-
{
|
|
53
|
-
value: name,
|
|
54
|
-
source: "name"
|
|
55
|
-
},
|
|
56
|
-
{
|
|
57
|
-
value: name ? `slack:${name}` : void 0,
|
|
58
|
-
source: "prefixed-name"
|
|
59
|
-
},
|
|
60
|
-
{
|
|
61
|
-
value: slug,
|
|
62
|
-
source: "slug"
|
|
63
|
-
}
|
|
64
|
-
] : []
|
|
65
|
-
]
|
|
66
|
-
});
|
|
67
|
-
}
|
|
68
|
-
function allowListMatches(params) {
|
|
69
|
-
return resolveSlackAllowListMatch(params).allowed;
|
|
70
|
-
}
|
|
71
|
-
function resolveSlackUserAllowed(params) {
|
|
72
|
-
const allowList = normalizeAllowListLower(params.allowList);
|
|
73
|
-
if (allowList.length === 0) return true;
|
|
74
|
-
return allowListMatches({
|
|
75
|
-
allowList,
|
|
76
|
-
id: params.userId,
|
|
77
|
-
name: params.userName,
|
|
78
|
-
allowNameMatching: params.allowNameMatching
|
|
79
|
-
});
|
|
80
|
-
}
|
|
81
|
-
//#endregion
|
|
82
|
-
export { normalizeSlackSlug as a, normalizeSlackAllowOwnerEntry as i, normalizeAllowList as n, resolveSlackAllowListMatch as o, normalizeAllowListLower as r, resolveSlackUserAllowed as s, allowListMatches as t };
|
|
@@ -1,232 +0,0 @@
|
|
|
1
|
-
import { s as truncateSlackText } from "./thread-ts-ks-O8cEG.js";
|
|
2
|
-
import { normalizeOptionalString } from "openclaw/plugin-sdk/string-coerce-runtime";
|
|
3
|
-
import { reduceInteractiveReply } from "openclaw/plugin-sdk/interactive-runtime";
|
|
4
|
-
//#region extensions/slack/src/reply-action-ids.ts
|
|
5
|
-
const SLACK_REPLY_BUTTON_ACTION_ID = "openclaw:reply_button";
|
|
6
|
-
const SLACK_REPLY_SELECT_ACTION_ID = "openclaw:reply_select";
|
|
7
|
-
//#endregion
|
|
8
|
-
//#region extensions/slack/src/blocks-render.ts
|
|
9
|
-
const SLACK_SECTION_TEXT_MAX = 3e3;
|
|
10
|
-
const SLACK_PLAIN_TEXT_MAX = 75;
|
|
11
|
-
const SLACK_OPTION_VALUE_MAX = 150;
|
|
12
|
-
const SLACK_BUTTON_VALUE_MAX = 2e3;
|
|
13
|
-
const SLACK_BUTTON_URL_MAX = 3e3;
|
|
14
|
-
const SLACK_STATIC_SELECT_OPTIONS_MAX = 100;
|
|
15
|
-
const SLACK_ACTION_BLOCK_ELEMENTS_MAX = 25;
|
|
16
|
-
function buildSlackReplyButtonActionId(buttonIndex, choiceIndex) {
|
|
17
|
-
return `${SLACK_REPLY_BUTTON_ACTION_ID}:${String(buttonIndex)}:${String(choiceIndex + 1)}`;
|
|
18
|
-
}
|
|
19
|
-
function buildSlackReplySelectActionId(selectIndex) {
|
|
20
|
-
return `${SLACK_REPLY_SELECT_ACTION_ID}:${String(selectIndex)}`;
|
|
21
|
-
}
|
|
22
|
-
function resolveSlackButtonStyle(style) {
|
|
23
|
-
if (style === "primary" || style === "danger") return style;
|
|
24
|
-
if (style === "success") return "primary";
|
|
25
|
-
}
|
|
26
|
-
function isWithinSlackLimit(value, maxLength) {
|
|
27
|
-
return value.length <= maxLength;
|
|
28
|
-
}
|
|
29
|
-
function readSlackBlockId(block) {
|
|
30
|
-
const value = block.block_id;
|
|
31
|
-
return typeof value === "string" ? value : void 0;
|
|
32
|
-
}
|
|
33
|
-
function readSlackOpenClawBlockIndex(blockId, prefix) {
|
|
34
|
-
if (!blockId.startsWith(prefix)) return;
|
|
35
|
-
const value = Number.parseInt(blockId.slice(prefix.length), 10);
|
|
36
|
-
return Number.isSafeInteger(value) && value > 0 ? value : void 0;
|
|
37
|
-
}
|
|
38
|
-
/** Resolve existing OpenClaw Block Kit indexes so appended controls keep stable unique IDs. */
|
|
39
|
-
function resolveSlackInteractiveBlockOffsets(blocks) {
|
|
40
|
-
let buttonIndexOffset = 0;
|
|
41
|
-
let selectIndexOffset = 0;
|
|
42
|
-
for (const block of blocks ?? []) {
|
|
43
|
-
const blockId = readSlackBlockId(block);
|
|
44
|
-
if (!blockId) continue;
|
|
45
|
-
buttonIndexOffset = Math.max(buttonIndexOffset, readSlackOpenClawBlockIndex(blockId, "openclaw_reply_buttons_") ?? 0);
|
|
46
|
-
selectIndexOffset = Math.max(selectIndexOffset, readSlackOpenClawBlockIndex(blockId, "openclaw_reply_select_") ?? 0);
|
|
47
|
-
}
|
|
48
|
-
return {
|
|
49
|
-
buttonIndexOffset,
|
|
50
|
-
selectIndexOffset
|
|
51
|
-
};
|
|
52
|
-
}
|
|
53
|
-
/**
|
|
54
|
-
* @deprecated Use buildSlackPresentationBlocks with MessagePresentation.
|
|
55
|
-
*/
|
|
56
|
-
function buildSlackInteractiveBlocks(interactive, options = {}) {
|
|
57
|
-
return reduceInteractiveReply(interactive, {
|
|
58
|
-
blocks: [],
|
|
59
|
-
buttonIndex: options.buttonIndexOffset ?? 0,
|
|
60
|
-
selectIndex: options.selectIndexOffset ?? 0
|
|
61
|
-
}, (state, block) => {
|
|
62
|
-
if (block.type === "text") {
|
|
63
|
-
const trimmed = block.text.trim();
|
|
64
|
-
if (!trimmed) return state;
|
|
65
|
-
state.blocks.push({
|
|
66
|
-
type: "section",
|
|
67
|
-
text: {
|
|
68
|
-
type: "mrkdwn",
|
|
69
|
-
text: truncateSlackText(trimmed, SLACK_SECTION_TEXT_MAX)
|
|
70
|
-
}
|
|
71
|
-
});
|
|
72
|
-
return state;
|
|
73
|
-
}
|
|
74
|
-
if (block.type === "buttons") {
|
|
75
|
-
const elements = block.buttons.flatMap((button, choiceIndex) => {
|
|
76
|
-
const value = button.value && isWithinSlackLimit(button.value, SLACK_BUTTON_VALUE_MAX) ? button.value : void 0;
|
|
77
|
-
const url = button.url && isWithinSlackLimit(button.url, SLACK_BUTTON_URL_MAX) ? button.url : void 0;
|
|
78
|
-
if (!value && !url) return [];
|
|
79
|
-
const style = resolveSlackButtonStyle(button.style);
|
|
80
|
-
return [{
|
|
81
|
-
type: "button",
|
|
82
|
-
action_id: buildSlackReplyButtonActionId(state.buttonIndex + 1, choiceIndex),
|
|
83
|
-
text: {
|
|
84
|
-
type: "plain_text",
|
|
85
|
-
text: truncateSlackText(button.label, SLACK_PLAIN_TEXT_MAX),
|
|
86
|
-
emoji: true
|
|
87
|
-
},
|
|
88
|
-
...value ? { value } : {},
|
|
89
|
-
...url ? { url } : {},
|
|
90
|
-
...style ? { style } : {}
|
|
91
|
-
}];
|
|
92
|
-
}).slice(0, SLACK_ACTION_BLOCK_ELEMENTS_MAX);
|
|
93
|
-
if (elements.length === 0) return state;
|
|
94
|
-
state.blocks.push({
|
|
95
|
-
type: "actions",
|
|
96
|
-
block_id: `openclaw_reply_buttons_${++state.buttonIndex}`,
|
|
97
|
-
elements
|
|
98
|
-
});
|
|
99
|
-
return state;
|
|
100
|
-
}
|
|
101
|
-
const options = block.options.filter((option) => isWithinSlackLimit(option.value, SLACK_OPTION_VALUE_MAX)).slice(0, SLACK_STATIC_SELECT_OPTIONS_MAX);
|
|
102
|
-
if (options.length === 0) return state;
|
|
103
|
-
state.blocks.push({
|
|
104
|
-
type: "actions",
|
|
105
|
-
block_id: `openclaw_reply_select_${++state.selectIndex}`,
|
|
106
|
-
elements: [{
|
|
107
|
-
type: "static_select",
|
|
108
|
-
action_id: buildSlackReplySelectActionId(state.selectIndex),
|
|
109
|
-
placeholder: {
|
|
110
|
-
type: "plain_text",
|
|
111
|
-
text: truncateSlackText(normalizeOptionalString(block.placeholder) ?? "Choose an option", SLACK_PLAIN_TEXT_MAX),
|
|
112
|
-
emoji: true
|
|
113
|
-
},
|
|
114
|
-
options: options.map((option, _choiceIndex) => ({
|
|
115
|
-
text: {
|
|
116
|
-
type: "plain_text",
|
|
117
|
-
text: truncateSlackText(option.label, SLACK_PLAIN_TEXT_MAX),
|
|
118
|
-
emoji: true
|
|
119
|
-
},
|
|
120
|
-
value: option.value
|
|
121
|
-
}))
|
|
122
|
-
}]
|
|
123
|
-
});
|
|
124
|
-
return state;
|
|
125
|
-
}).blocks;
|
|
126
|
-
}
|
|
127
|
-
/** Render portable presentation blocks as Slack Block Kit blocks. */
|
|
128
|
-
function buildSlackPresentationBlocks(presentation, options = {}) {
|
|
129
|
-
if (!presentation) return [];
|
|
130
|
-
const blocks = [];
|
|
131
|
-
if (presentation.title) blocks.push({
|
|
132
|
-
type: "header",
|
|
133
|
-
text: {
|
|
134
|
-
type: "plain_text",
|
|
135
|
-
text: truncateSlackText(presentation.title, 150),
|
|
136
|
-
emoji: true
|
|
137
|
-
}
|
|
138
|
-
});
|
|
139
|
-
for (const block of presentation.blocks) {
|
|
140
|
-
if (block.type === "text" || block.type === "context") {
|
|
141
|
-
const text = block.text.trim();
|
|
142
|
-
if (!text) continue;
|
|
143
|
-
if (block.type === "context") blocks.push({
|
|
144
|
-
type: "context",
|
|
145
|
-
elements: [{
|
|
146
|
-
type: "mrkdwn",
|
|
147
|
-
text: truncateSlackText(text, SLACK_SECTION_TEXT_MAX)
|
|
148
|
-
}]
|
|
149
|
-
});
|
|
150
|
-
else blocks.push({
|
|
151
|
-
type: "section",
|
|
152
|
-
text: {
|
|
153
|
-
type: "mrkdwn",
|
|
154
|
-
text: truncateSlackText(text, SLACK_SECTION_TEXT_MAX)
|
|
155
|
-
}
|
|
156
|
-
});
|
|
157
|
-
continue;
|
|
158
|
-
}
|
|
159
|
-
if (block.type === "divider") blocks.push({ type: "divider" });
|
|
160
|
-
}
|
|
161
|
-
let buttonIndex = options.buttonIndexOffset ?? 0;
|
|
162
|
-
let selectIndex = options.selectIndexOffset ?? 0;
|
|
163
|
-
for (const block of presentation.blocks) {
|
|
164
|
-
if (block.type === "buttons") {
|
|
165
|
-
const rendered = buildSlackPresentationButtonBlock(block, buttonIndex + 1);
|
|
166
|
-
if (rendered) {
|
|
167
|
-
buttonIndex += 1;
|
|
168
|
-
blocks.push(rendered);
|
|
169
|
-
}
|
|
170
|
-
continue;
|
|
171
|
-
}
|
|
172
|
-
if (block.type === "select") {
|
|
173
|
-
const rendered = buildSlackPresentationSelectBlock(block, selectIndex + 1);
|
|
174
|
-
if (rendered) {
|
|
175
|
-
selectIndex += 1;
|
|
176
|
-
blocks.push(rendered);
|
|
177
|
-
}
|
|
178
|
-
}
|
|
179
|
-
}
|
|
180
|
-
return blocks;
|
|
181
|
-
}
|
|
182
|
-
function buildSlackPresentationButtonBlock(block, buttonIndex) {
|
|
183
|
-
const elements = block.buttons.flatMap((button, choiceIndex) => {
|
|
184
|
-
const value = button.value && isWithinSlackLimit(button.value, SLACK_BUTTON_VALUE_MAX) ? button.value : void 0;
|
|
185
|
-
const url = button.url && isWithinSlackLimit(button.url, SLACK_BUTTON_URL_MAX) ? button.url : void 0;
|
|
186
|
-
if (!value && !url) return [];
|
|
187
|
-
const style = resolveSlackButtonStyle(button.style);
|
|
188
|
-
return [{
|
|
189
|
-
type: "button",
|
|
190
|
-
action_id: buildSlackReplyButtonActionId(buttonIndex, choiceIndex),
|
|
191
|
-
text: {
|
|
192
|
-
type: "plain_text",
|
|
193
|
-
text: truncateSlackText(button.label, SLACK_PLAIN_TEXT_MAX),
|
|
194
|
-
emoji: true
|
|
195
|
-
},
|
|
196
|
-
...value ? { value } : {},
|
|
197
|
-
...url ? { url } : {},
|
|
198
|
-
...style ? { style } : {}
|
|
199
|
-
}];
|
|
200
|
-
}).slice(0, SLACK_ACTION_BLOCK_ELEMENTS_MAX);
|
|
201
|
-
return elements.length > 0 ? {
|
|
202
|
-
type: "actions",
|
|
203
|
-
block_id: `openclaw_reply_buttons_${buttonIndex}`,
|
|
204
|
-
elements
|
|
205
|
-
} : void 0;
|
|
206
|
-
}
|
|
207
|
-
function buildSlackPresentationSelectBlock(block, selectIndex) {
|
|
208
|
-
const options = block.options.filter((option) => isWithinSlackLimit(option.value, SLACK_OPTION_VALUE_MAX)).slice(0, SLACK_STATIC_SELECT_OPTIONS_MAX);
|
|
209
|
-
return options.length > 0 ? {
|
|
210
|
-
type: "actions",
|
|
211
|
-
block_id: `openclaw_reply_select_${selectIndex}`,
|
|
212
|
-
elements: [{
|
|
213
|
-
type: "static_select",
|
|
214
|
-
action_id: buildSlackReplySelectActionId(selectIndex),
|
|
215
|
-
placeholder: {
|
|
216
|
-
type: "plain_text",
|
|
217
|
-
text: truncateSlackText(normalizeOptionalString(block.placeholder) ?? "Choose an option", SLACK_PLAIN_TEXT_MAX),
|
|
218
|
-
emoji: true
|
|
219
|
-
},
|
|
220
|
-
options: options.map((option) => ({
|
|
221
|
-
text: {
|
|
222
|
-
type: "plain_text",
|
|
223
|
-
text: truncateSlackText(option.label, SLACK_PLAIN_TEXT_MAX),
|
|
224
|
-
emoji: true
|
|
225
|
-
},
|
|
226
|
-
value: option.value
|
|
227
|
-
}))
|
|
228
|
-
}]
|
|
229
|
-
} : void 0;
|
|
230
|
-
}
|
|
231
|
-
//#endregion
|
|
232
|
-
export { SLACK_REPLY_SELECT_ACTION_ID as a, SLACK_REPLY_BUTTON_ACTION_ID as i, buildSlackPresentationBlocks as n, resolveSlackInteractiveBlockOffsets as r, buildSlackInteractiveBlocks as t };
|