@openclaw/slack 2026.9.1-beta.1 → 2026.9.2

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.
Files changed (99) hide show
  1. package/dist/{account-inspect-CN2hBsim.js → account-inspect-C3sePHWa.js} +3 -3
  2. package/dist/account-inspect-api.js +1 -1
  3. package/dist/{action-runtime-BoSeX09X.js → action-runtime-DftQWpI4.js} +84 -66
  4. package/dist/action-runtime.runtime-rHI3UAh4.js +2 -0
  5. package/dist/{actions-XdQyjG_p.js → actions-CFkvEv1d.js} +198 -54
  6. package/dist/api.js +14 -14
  7. package/dist/{approval-handler.runtime-DxXfGX_Z.js → approval-handler.runtime-BeILKdw4.js} +47 -25
  8. package/dist/{channel-C_vnTgxo.js → channel-CmOuxbOD.js} +76 -133
  9. package/dist/channel-config-api.js +1 -1
  10. package/dist/channel-plugin-api.js +1 -1
  11. package/dist/{channel-type-j-2lalcC.js → channel-type-BWt2CRaI.js} +2 -2
  12. package/dist/{channel.setup-aal8tokM.js → channel.setup-D5z1ReaT.js} +29 -23
  13. package/dist/{config-schema-CN3XZRX5.js → config-schema-JDx_f9Zb.js} +26 -17
  14. package/dist/{cursor-pages-eX7p8Wwt.js → cursor-pages-ByFwo-Py.js} +7 -1
  15. package/dist/{directory-config-DqfQ42OV.js → directory-config-Bmw4ykSy.js} +4 -3
  16. package/dist/directory-contract-api.js +1 -1
  17. package/dist/{directory-live-lC6X_Ru-.js → directory-live-BuBPHmju.js} +3 -8
  18. package/dist/{doctor-contract-BAy7-EUQ.js → doctor-contract-BNjw9bxb.js} +5 -4
  19. package/dist/doctor-contract-api.js +1 -1
  20. package/dist/{message-tool-api-CWosHSi5.js → message-tool-api-uNEfQYGY.js} +19 -2
  21. package/dist/message-tool-api.js +1 -1
  22. package/dist/{monitor-DrNCGneD.js → monitor-DI07pfJl.js} +3 -3
  23. package/dist/{outbound-adapter-DkT2vUE9.js → outbound-adapter-B5QyTRpJ.js} +96 -91
  24. package/dist/{pipeline.runtime-CRRng_Nw.js → pipeline.runtime-BdIwZgm4.js} +596 -920
  25. package/dist/{policy-BoP6t88v.js → policy-Bh5TOqII.js} +7 -4
  26. package/dist/{probe-4_aHtVT3.js → probe-Biy--yhL.js} +251 -12
  27. package/dist/{provider-D4nDgxCh.js → provider-DoaUvAM4.js} +5621 -4944
  28. package/dist/{relay-source-CEmze11m.js → relay-source-D4uecp68.js} +6 -4
  29. package/dist/{replies-D9XMM_S0.js → replies-DENuTcPO.js} +21 -16
  30. package/dist/reply-blocks-PRkhyAN7.js +790 -0
  31. package/dist/{resolve-channels-DSamDgVs.js → resolve-channels-DQGV2VrE.js} +6 -10
  32. package/dist/{resolve-users-CIzwbaJR.js → resolve-users-DRGt_Q4I.js} +5 -4
  33. package/dist/runtime-api.js +10 -10
  34. package/dist/{scopes-BBrUzpBH.js → scopes-CZzeGdWV.js} +1 -1
  35. package/dist/{send-DtjEnlLh.js → send-DElUcgIs.js} +32 -24
  36. package/dist/send-results-eeOu_HYm.js +23 -0
  37. package/dist/{send.runtime-DQeNKa2J.js → send.runtime-C8D6cKGm.js} +1 -1
  38. package/dist/{group-policy-CU1tEGpS.js → session-status-BynwcZSO.js} +284 -1013
  39. package/dist/setup-plugin-api.js +1 -1
  40. package/dist/{setup-surface-CsBCM4rP.js → setup-surface-B1_gpGBl.js} +5 -5
  41. package/dist/{shared-D9GeeR9K.js → shared-CNQsWJT7.js} +7 -5
  42. package/dist/{slash-dispatch.runtime-Chr3YHnT.js → slash-dispatch.runtime-DhsXavSY.js} +2 -2
  43. package/dist/{target-parsing-BnMD2ZqZ.js → target-parsing-PbxGDbr9.js} +11 -6
  44. package/dist/{targets-Cx5W_n3W.js → targets-7FexXJ62.js} +1 -1
  45. package/dist/{thread-ts-DUGhaYKq.js → thread-ts-CukseRVL.js} +5 -1
  46. package/node_modules/@slack/bolt/node_modules/negotiator/lib/accept.js +54 -0
  47. package/node_modules/@slack/bolt/node_modules/negotiator/lib/charset.js +10 -34
  48. package/node_modules/@slack/bolt/node_modules/negotiator/lib/encoding.js +9 -30
  49. package/node_modules/@slack/bolt/node_modules/negotiator/lib/language.js +15 -36
  50. package/node_modules/@slack/bolt/node_modules/negotiator/lib/mediaType.js +16 -134
  51. package/node_modules/@slack/bolt/node_modules/negotiator/node_modules/content-type/LICENSE +22 -0
  52. package/node_modules/@slack/bolt/node_modules/negotiator/node_modules/content-type/README.md +71 -0
  53. package/node_modules/@slack/bolt/node_modules/negotiator/node_modules/content-type/dist/index.d.ts +46 -0
  54. package/node_modules/@slack/bolt/node_modules/negotiator/node_modules/content-type/dist/index.js +176 -0
  55. package/node_modules/@slack/bolt/node_modules/negotiator/node_modules/content-type/dist/index.js.map +1 -0
  56. package/node_modules/@slack/bolt/node_modules/negotiator/node_modules/content-type/package.json +52 -0
  57. package/node_modules/@slack/bolt/node_modules/negotiator/package.json +16 -10
  58. package/node_modules/typebox/build/format/email.mjs +1 -1
  59. package/node_modules/typebox/build/format/idna/idn-hostname.mjs +19 -1
  60. package/node_modules/typebox/build/format/json_pointer.d.mts +2 -2
  61. package/node_modules/typebox/build/format/json_pointer.mjs +2 -2
  62. package/node_modules/typebox/build/format/json_pointer_uri_fragment.d.mts +2 -2
  63. package/node_modules/typebox/build/format/json_pointer_uri_fragment.mjs +2 -2
  64. package/node_modules/typebox/build/format/relative_json_pointer.d.mts +2 -2
  65. package/node_modules/typebox/build/format/relative_json_pointer.mjs +2 -2
  66. package/node_modules/typebox/build/system/memory/assign.mjs +2 -1
  67. package/node_modules/typebox/build/system/memory/create.mjs +3 -4
  68. package/node_modules/typebox/build/system/memory/discard.mjs +2 -2
  69. package/node_modules/typebox/build/system/memory/freeze.d.mts +4 -0
  70. package/node_modules/typebox/build/system/memory/freeze.mjs +6 -0
  71. package/node_modules/typebox/build/system/memory/update.mjs +3 -2
  72. package/node_modules/typebox/package.json +1 -1
  73. package/node_modules/undici/lib/dispatcher/balanced-pool.js +4 -2
  74. package/node_modules/undici/lib/dispatcher/client-h1.js +12 -4
  75. package/node_modules/undici/lib/dispatcher/client-h2.js +70 -14
  76. package/node_modules/undici/lib/dispatcher/client.js +6 -2
  77. package/node_modules/undici/lib/handler/cache-handler.js +21 -5
  78. package/node_modules/undici/lib/handler/retry-handler.js +42 -7
  79. package/node_modules/undici/lib/interceptor/cache.js +20 -1
  80. package/node_modules/undici/lib/interceptor/decompress.js +146 -14
  81. package/node_modules/undici/lib/interceptor/dump.js +10 -23
  82. package/node_modules/undici/lib/web/eventsource/eventsource-stream.js +245 -150
  83. package/node_modules/undici/lib/web/websocket/connection.js +1 -1
  84. package/node_modules/undici/lib/web/websocket/permessage-deflate.js +5 -0
  85. package/node_modules/undici/lib/web/websocket/stream/websocketstream.js +8 -10
  86. package/node_modules/undici/package.json +1 -1
  87. package/node_modules/undici/types/interceptors.d.ts +2 -0
  88. package/openclaw.plugin.json +17 -9
  89. package/package.json +6 -6
  90. package/skills/_vendor/slack-skills-plugin.LICENSE +21 -0
  91. package/skills/_vendor/slack-skills-plugin.json +31 -0
  92. package/skills/block-kit/SKILL.md +37 -0
  93. package/skills/block-kit/references/official-block-kit.md +257 -0
  94. package/skills/block-kit/references/official-common-patterns.md +385 -0
  95. package/skills/slack/SKILL.md +1 -1
  96. package/dist/action-runtime.runtime-Dpa16J87.js +0 -2
  97. package/dist/conversation-binding-route-DFVLUdYF.js +0 -115
  98. package/dist/slack-client-kind-hSfjXyUM.js +0 -94
  99. package/node_modules/@slack/bolt/node_modules/negotiator/HISTORY.md +0 -114
@@ -1,7 +1,7 @@
1
1
  import { t as __exportAll } from "./rolldown-runtime-8H4AJuhK.js";
2
2
  import { a as resolveSlackAccount } from "./accounts-Dm_H77gH.js";
3
- import { i as createSlackLookupClient } from "./probe-4_aHtVT3.js";
4
- import { t as collectSlackCursorPages } from "./cursor-pages-eX7p8Wwt.js";
3
+ import { s as createSlackLookupClient } from "./probe-Biy--yhL.js";
4
+ import { n as fetchSlackChannelListPage, t as collectSlackCursorPages } from "./cursor-pages-ByFwo-Py.js";
5
5
  import { normalizeLowercaseStringOrEmpty, normalizeOptionalLowercaseString, normalizeOptionalString } from "openclaw/plugin-sdk/string-coerce-runtime";
6
6
  //#region extensions/slack/src/directory-live.ts
7
7
  var directory_live_exports = /* @__PURE__ */ __exportAll({
@@ -91,12 +91,7 @@ async function listSlackDirectoryGroupsLive(params) {
91
91
  if (!client) return [];
92
92
  const query = normalizeQuery(params.query);
93
93
  const rows = (await collectSlackCursorPages({
94
- fetchPage: (cursor) => client.conversations.list({
95
- types: "public_channel,private_channel",
96
- exclude_archived: false,
97
- limit: 1e3,
98
- cursor
99
- }),
94
+ fetchPage: (cursor) => fetchSlackChannelListPage(client, cursor),
100
95
  collectPageItems: (res) => Array.isArray(res.channels) ? res.channels : []
101
96
  })).filter((channel) => {
102
97
  const name = normalizeOptionalLowercaseString(channel.name);
@@ -171,11 +171,12 @@ function normalizeCompatibilityConfig({ cfg }) {
171
171
  scope: "root-and-accounts",
172
172
  onRemove: ({ key, pathPrefix }) => changes.push(`Removed retired ${pathPrefix}.${key}; Slack detects org-wide installations automatically.`)
173
173
  });
174
+ const aliases = streamingAliasMigration.normalizeChannelConfig({
175
+ cfg: retired.config,
176
+ changes
177
+ });
174
178
  return normalizeChannelConfigEntries({
175
- cfg: streamingAliasMigration.normalizeChannelConfig({
176
- cfg: retired.config,
177
- changes
178
- }).config,
179
+ cfg: aliases.config,
179
180
  channelId: "slack",
180
181
  changes,
181
182
  normalizeEntry: normalizeSlackEntry
@@ -1,2 +1,2 @@
1
- import { n as normalizeCompatibilityConfig, t as legacyConfigRules } from "./doctor-contract-BAy7-EUQ.js";
1
+ import { n as normalizeCompatibilityConfig, t as legacyConfigRules } from "./doctor-contract-BNjw9bxb.js";
2
2
  export { legacyConfigRules, normalizeCompatibilityConfig };
@@ -1,6 +1,6 @@
1
1
  import { n as listSlackAccountIds } from "./accounts-Dm_H77gH.js";
2
- import { t as inspectSlackAccount } from "./account-inspect-CN2hBsim.js";
3
- import { n as resolveSlackThreadTsValue, t as normalizeSlackThreadTsCandidate } from "./thread-ts-DUGhaYKq.js";
2
+ import { t as inspectSlackAccount } from "./account-inspect-C3sePHWa.js";
3
+ import { r as resolveSlackThreadTsValue, t as normalizeSlackThreadTsCandidate } from "./thread-ts-CukseRVL.js";
4
4
  import { createActionGate } from "openclaw/plugin-sdk/channel-actions";
5
5
  import { extractToolSend } from "openclaw/plugin-sdk/tool-send";
6
6
  import { Type } from "typebox";
@@ -24,6 +24,7 @@ function listSlackMessageActions(cfg, accountId) {
24
24
  actions.add("reactions");
25
25
  }
26
26
  if (isActionEnabled("messages")) {
27
+ actions.add("conversation-open");
27
28
  actions.add("read");
28
29
  actions.add("edit");
29
30
  actions.add("delete");
@@ -106,6 +107,22 @@ function describeSlackMessageTool({ cfg, accountId }) {
106
107
  const actions = listSlackMessageActions(cfg, accountId);
107
108
  const capabilities = /* @__PURE__ */ new Set();
108
109
  const schema = [];
110
+ if (actions.includes("conversation-open")) schema.push({
111
+ actions: ["conversation-open"],
112
+ visibility: "all-configured",
113
+ properties: {
114
+ userIds: Type.Optional(Type.Array(Type.String({ pattern: "^[UW][A-Z0-9]+$" }), {
115
+ minItems: 1,
116
+ maxItems: 8,
117
+ uniqueItems: true,
118
+ description: "Slack conversation-open: 1-8 other member IDs. One opens a DM; multiple open or reuse a group DM. Exclude the calling account. Use the returned target with action=\"send\"."
119
+ })),
120
+ teamId: Type.Optional(Type.String({
121
+ pattern: "^T[A-Z0-9]+$",
122
+ description: "Slack workspace for conversation-open. Defaults to the trusted current workspace for the selected account; required for detached Enterprise operations."
123
+ }))
124
+ }
125
+ });
109
126
  if (actions.includes("send")) capabilities.add("presentation");
110
127
  if (actions.includes("download-file")) schema.push({
111
128
  properties: createSlackFileActionSchema(),
@@ -1,2 +1,2 @@
1
- import { t as describeSlackMessageTool } from "./message-tool-api-CWosHSi5.js";
1
+ import { t as describeSlackMessageTool } from "./message-tool-api-uNEfQYGY.js";
2
2
  export { describeSlackMessageTool as describeMessageTool };
@@ -1,7 +1,7 @@
1
1
  import { t as __exportAll } from "./rolldown-runtime-8H4AJuhK.js";
2
- import { T as buildSlackSlashCommandMatcher, t as monitorSlackProvider } from "./provider-D4nDgxCh.js";
3
- import { t as isSlackChannelAllowedByPolicy } from "./policy-BoP6t88v.js";
4
- import { o as resolveSlackThreadTs } from "./replies-D9XMM_S0.js";
2
+ import { M as buildSlackSlashCommandMatcher, t as monitorSlackProvider } from "./provider-DoaUvAM4.js";
3
+ import { t as isSlackChannelAllowedByPolicy } from "./policy-Bh5TOqII.js";
4
+ import { a as resolveSlackThreadTs } from "./replies-DENuTcPO.js";
5
5
  //#region extensions/slack/src/monitor.ts
6
6
  var monitor_exports = /* @__PURE__ */ __exportAll({
7
7
  buildSlackSlashCommandMatcher: () => buildSlackSlashCommandMatcher,
@@ -1,24 +1,27 @@
1
- import { a as parseSlackTarget } from "./target-parsing-BnMD2ZqZ.js";
2
- import { B as SLACK_TEXT_LIMIT, I as resolveSlackAuthoredTextPlacement, ct as escapeSlackMrkdwn, dt as SLACK_PRESENTATION_CAPABILITIES, q as SLACK_QUESTION_FINALIZATION_BLOCKS, tt as resolveSlackQuestionActionIds, v as parseSlackReplyBlockSegments, x as resolveSlackReplyDeliveryMessages, y as resolveSlackReplyBlockResolution } from "./group-policy-CU1tEGpS.js";
3
- import { n as resolveSlackThreadTsValue } from "./thread-ts-DUGhaYKq.js";
1
+ import { a as resolveSlackAccount, l as resolveSlackOperationToken } from "./accounts-Dm_H77gH.js";
2
+ import { K as resolveSlackQuestionActionIds, R as SLACK_QUESTION_FINALIZATION_BLOCKS, at as escapeSlackMrkdwn, f as assertSlackDetachedTargetAllowed, k as SLACK_TEXT_LIMIT } from "./session-status-BynwcZSO.js";
3
+ import { a as parseSlackTarget } from "./target-parsing-PbxGDbr9.js";
4
+ import { a as resolveSlackReplyDeliveryMessages, h as SLACK_PRESENTATION_CAPABILITIES, n as parseSlackReplyBlockSegments, r as resolveSlackReplyBlockResolution, s as resolveSlackAuthoredTextPlacement } from "./reply-blocks-PRkhyAN7.js";
5
+ import { r as resolveSlackThreadTsValue } from "./thread-ts-CukseRVL.js";
6
+ import { t as mergeSlackSendResults } from "./send-results-eeOu_HYm.js";
4
7
  import { normalizeOptionalString } from "openclaw/plugin-sdk/string-coerce-runtime";
5
- import { createMessageReceiptFromOutboundResults, resolveOutboundSendDep } from "openclaw/plugin-sdk/channel-outbound";
8
+ import { resolveOutboundSendDep } from "openclaw/plugin-sdk/channel-outbound";
6
9
  import { createLazyRuntimeModule } from "openclaw/plugin-sdk/lazy-runtime";
7
10
  import { normalizeMessagePresentation, resolveLegacyInteractiveTextFallback } from "openclaw/plugin-sdk/interactive-runtime";
11
+ import { resolvePayloadMediaUrls, sendPayloadMediaSequenceAndFinalize, sendTextMediaPayload } from "openclaw/plugin-sdk/reply-payload";
8
12
  import { questionGatewayRuntime } from "openclaw/plugin-sdk/question-gateway-runtime";
9
13
  import { createHmac, randomBytes, timingSafeEqual } from "node:crypto";
10
- import { resolvePayloadMediaUrls, sendPayloadMediaSequenceAndFinalize, sendTextMediaPayload } from "openclaw/plugin-sdk/reply-payload";
11
- import { attachChannelToResult, createAttachedChannelResultAdapter } from "openclaw/plugin-sdk/channel-send-result";
14
+ import { attachChannelToResult } from "openclaw/plugin-sdk/channel-send-result";
12
15
  //#region extensions/slack/src/outbound-adapter.ts
13
16
  function toSlackOutboundResult(result) {
14
17
  const { channelId, ...delivery } = result;
15
- return channelId === void 0 ? delivery : {
18
+ return attachChannelToResult("slack", channelId === void 0 ? delivery : {
16
19
  ...delivery,
17
20
  target: {
18
21
  kind: "channel",
19
22
  id: channelId
20
23
  }
21
- };
24
+ });
22
25
  }
23
26
  const SLACK_RENDERED_PRESENTATION_PROVENANCE_KEY = randomBytes(32);
24
27
  function createSlackRenderedPresentationProvenance(resolution) {
@@ -49,7 +52,7 @@ function readSlackRenderedPresentation(slackData) {
49
52
  return;
50
53
  }
51
54
  }
52
- const loadSlackSendRuntime = createLazyRuntimeModule(() => import("./send.runtime-DQeNKa2J.js"));
55
+ const loadSlackSendRuntime = createLazyRuntimeModule(() => import("./send.runtime-C8D6cKGm.js"));
53
56
  function resolveSlackSendIdentity(identity) {
54
57
  if (!identity) return;
55
58
  const username = normalizeOptionalString(identity.name);
@@ -97,43 +100,45 @@ function withSlackRenderedPresentation(payload, slackData, resolution) {
97
100
  function readSlackAuthoredTextPlacement(value) {
98
101
  return value === "none" || value === "blocks" || value === "outside-blocks" ? value : void 0;
99
102
  }
100
- async function sendSlackOutboundMessage(params) {
101
- const send = resolveOutboundSendDep(params.deps, "slack") ?? (await loadSlackSendRuntime()).sendMessageSlack;
102
- const slackIdentity = resolveSlackSendIdentity(params.identity);
103
- const threadTs = resolveSlackThreadTsValue({
104
- replyToId: params.replyToId,
105
- threadId: params.threadId
103
+ async function prepareSlackOutboundSend(ctx) {
104
+ const account = resolveSlackAccount({
105
+ cfg: ctx.cfg,
106
+ accountId: ctx.accountId
106
107
  });
107
- const sendOptions = {
108
- cfg: params.cfg,
109
- threadTs,
110
- accountId: params.accountId ?? void 0,
111
- ...params.mediaUrl ? {
112
- mediaUrl: params.mediaUrl,
113
- mediaAccess: params.mediaAccess,
114
- mediaLocalRoots: params.mediaLocalRoots,
115
- mediaReadFile: params.mediaReadFile,
116
- ...params.forceDocument ? { forceDocument: true } : {}
117
- } : {},
118
- ...params.blocks ? { blocks: params.blocks } : {},
119
- ...params.authoredTextPlacement ? { authoredTextPlacement: params.authoredTextPlacement } : {},
120
- ...Object.hasOwn(params, "nativeDataFallbackBaseText") ? { nativeDataFallbackBaseText: params.nativeDataFallbackBaseText } : {},
121
- ...params.textIsSlackPlainText ? { textIsSlackPlainText: true } : {},
122
- ...slackIdentity ? { identity: slackIdentity } : {},
123
- ...params.deliveryQueueId ? { deliveryQueueId: params.deliveryQueueId } : {},
124
- ...params.onPlatformSendDispatch ? { onPlatformSendDispatch: params.onPlatformSendDispatch } : {},
125
- ...params.onDeliveryResult ? { onDeliveryResult: async (progress) => {
126
- await params.onDeliveryResult?.(attachChannelToResult("slack", toSlackOutboundResult(progress)));
127
- } } : {}
108
+ const target = parseSlackTarget(ctx.to, { defaultKind: "channel" });
109
+ assertSlackDetachedTargetAllowed(account.accountId, target?.teamId);
110
+ const send = resolveOutboundSendDep(ctx.deps, "slack") ?? (await loadSlackSendRuntime()).sendMessageSlack;
111
+ const token = resolveSlackOperationToken(account, "write");
112
+ const botToken = account.botToken?.trim();
113
+ const tokenOverride = token && token !== botToken ? token : void 0;
114
+ return async (params) => {
115
+ const slackIdentity = resolveSlackSendIdentity(params.identity);
116
+ const threadTs = resolveSlackThreadTsValue(params);
117
+ const sendOptions = {
118
+ cfg: params.cfg,
119
+ ...tokenOverride ? { token: tokenOverride } : {},
120
+ threadTs,
121
+ accountId: params.accountId ?? void 0,
122
+ ...params.mediaUrl ? {
123
+ mediaUrl: params.mediaUrl,
124
+ mediaAccess: params.mediaAccess,
125
+ mediaLocalRoots: params.mediaLocalRoots,
126
+ mediaReadFile: params.mediaReadFile,
127
+ ...params.forceDocument ? { forceDocument: true } : {}
128
+ } : {},
129
+ ...params.blocks ? { blocks: params.blocks } : {},
130
+ ...params.authoredTextPlacement ? { authoredTextPlacement: params.authoredTextPlacement } : {},
131
+ ...Object.hasOwn(params, "nativeDataFallbackBaseText") ? { nativeDataFallbackBaseText: params.nativeDataFallbackBaseText } : {},
132
+ ...params.textIsSlackPlainText ? { textIsSlackPlainText: true } : {},
133
+ ...slackIdentity ? { identity: slackIdentity } : {},
134
+ ...params.deliveryQueueId ? { deliveryQueueId: params.deliveryQueueId } : {},
135
+ ...params.onPlatformSendDispatch ? { onPlatformSendDispatch: params.onPlatformSendDispatch } : {},
136
+ ...params.onDeliveryResult ? { onDeliveryResult: async (progress) => {
137
+ await params.onDeliveryResult?.(toSlackOutboundResult(progress));
138
+ } } : {}
139
+ };
140
+ return await send(params.to, params.text, sendOptions);
128
141
  };
129
- return await send(params.to, params.text, sendOptions);
130
- }
131
- function createSlackAttachedSendAdapter() {
132
- return createAttachedChannelResultAdapter({
133
- channel: "slack",
134
- sendText: async (ctx) => toSlackOutboundResult(await sendSlackOutboundMessage(ctx)),
135
- sendMedia: async (ctx) => toSlackOutboundResult(await sendSlackOutboundMessage(ctx))
136
- });
137
142
  }
138
143
  const slackOutbound = {
139
144
  deliveryMode: "direct",
@@ -146,11 +151,19 @@ const slackOutbound = {
146
151
  return resolution.segments.length > 0 ? withSlackRenderedPresentation(payload, slackData, resolution) : null;
147
152
  },
148
153
  sendPayload: async (ctx) => {
154
+ const send = await prepareSlackOutboundSend(ctx);
155
+ const { mediaUrl: _mediaUrl, ...commonCtx } = ctx;
156
+ const preparedCtx = {
157
+ ...commonCtx,
158
+ replyToId: resolveSlackThreadTsValue(ctx),
159
+ threadId: null,
160
+ deliveryQueueId: void 0
161
+ };
149
162
  const payload = {
150
- ...ctx.payload,
163
+ ...preparedCtx.payload,
151
164
  text: resolveLegacyInteractiveTextFallback({
152
- text: ctx.payload.text,
153
- interactive: ctx.payload.interactive
165
+ text: preparedCtx.payload.text,
166
+ interactive: preparedCtx.payload.interactive
154
167
  }) ?? ""
155
168
  };
156
169
  const slackData = payload.channelData?.slack;
@@ -158,66 +171,50 @@ const slackOutbound = {
158
171
  let resolution;
159
172
  if (renderedResolution) resolution = renderedResolution;
160
173
  else resolution = resolveSlackOutboundBlockResolution(payload);
161
- if (resolution.segments.length === 0) return await sendTextMediaPayload({
162
- channel: "slack",
163
- ctx: {
164
- ...ctx,
165
- payload
166
- },
167
- adapter: slackOutbound
168
- });
174
+ if (resolution.segments.length === 0) {
175
+ const sendPart = async (part) => toSlackOutboundResult(await send(part));
176
+ return await sendTextMediaPayload({
177
+ channel: "slack",
178
+ ctx: {
179
+ ...preparedCtx,
180
+ payload
181
+ },
182
+ adapter: {
183
+ sendText: sendPart,
184
+ sendMedia: sendPart
185
+ }
186
+ });
187
+ }
169
188
  const mediaUrls = resolvePayloadMediaUrls(payload);
170
189
  const deliveryMessages = resolveSlackReplyDeliveryMessages({
171
190
  authoredTextPlacement: resolution.authoredTextPlacement,
172
191
  segments: resolution.segments,
173
192
  text: payload.text
174
193
  });
175
- const useSingleDeliveryMarker = mediaUrls.length === 0 && deliveryMessages.length === 1;
176
194
  const sentResults = [];
177
- return attachChannelToResult("slack", toSlackOutboundResult(await sendPayloadMediaSequenceAndFinalize({
195
+ return toSlackOutboundResult(await sendPayloadMediaSequenceAndFinalize({
178
196
  text: "",
179
197
  mediaUrls,
180
- send: async ({ text, mediaUrl }) => await sendSlackOutboundMessage({
181
- ...ctx,
198
+ send: async ({ text, mediaUrl }) => await send({
199
+ ...preparedCtx,
182
200
  text,
183
- mediaUrl,
184
- deliveryQueueId: useSingleDeliveryMarker ? ctx.deliveryQueueId : void 0
201
+ mediaUrl
185
202
  }),
186
203
  onResult: (result) => {
187
204
  sentResults.push(result);
188
205
  },
189
206
  finalize: async () => {
190
- let lastResult;
191
- for (const message of deliveryMessages) {
192
- lastResult = await sendSlackOutboundMessage({
193
- ...ctx,
194
- text: message.text,
195
- ...message.blocks ? { blocks: message.blocks } : {},
196
- ...message.authoredTextPlacement ? { authoredTextPlacement: message.authoredTextPlacement } : {},
197
- ...message.nativeDataFallbackBaseText ? { nativeDataFallbackBaseText: message.nativeDataFallbackBaseText } : {},
198
- ...message.textIsSlackPlainText ? { textIsSlackPlainText: true } : {},
199
- deliveryQueueId: useSingleDeliveryMarker ? ctx.deliveryQueueId : void 0
200
- });
201
- sentResults.push(lastResult);
202
- }
203
- if (!lastResult) throw new Error("Slack rendered presentation produced no deliverable segment");
204
- if (sentResults.length === 1) return lastResult;
205
- const receipt = createMessageReceiptFromOutboundResults({ results: sentResults });
206
- receipt.parts = receipt.parts.map((part, index) => ({
207
- ...part,
208
- index
207
+ for (const message of deliveryMessages) sentResults.push(await send({
208
+ ...preparedCtx,
209
+ text: message.text,
210
+ ...message.blocks ? { blocks: message.blocks } : {},
211
+ ...message.authoredTextPlacement ? { authoredTextPlacement: message.authoredTextPlacement } : {},
212
+ ...message.nativeDataFallbackBaseText ? { nativeDataFallbackBaseText: message.nativeDataFallbackBaseText } : {},
213
+ ...message.textIsSlackPlainText ? { textIsSlackPlainText: true } : {}
209
214
  }));
210
- const questionResult = sentResults.find((result) => result.meta?.slackQuestionActionIds.length);
211
- return {
212
- ...lastResult,
213
- receipt,
214
- ...questionResult?.meta ? { meta: {
215
- ...questionResult.meta,
216
- slackQuestionMessageId: questionResult.meta.slackQuestionMessageId ?? questionResult.messageId
217
- } } : {}
218
- };
215
+ return mergeSlackSendResults(sentResults);
219
216
  }
220
- })));
217
+ }));
221
218
  },
222
219
  afterDeliverPayload: async ({ cfg, target, payload, results }) => {
223
220
  const questionId = questionGatewayRuntime.readAskUserQuestionId(payload);
@@ -263,7 +260,15 @@ const slackOutbound = {
263
260
  }
264
261
  });
265
262
  },
266
- ...createSlackAttachedSendAdapter()
263
+ sendText: async (ctx) => {
264
+ return toSlackOutboundResult(await (await prepareSlackOutboundSend(ctx))(ctx));
265
+ },
266
+ sendMedia: async (ctx) => {
267
+ return toSlackOutboundResult(await (await prepareSlackOutboundSend(ctx))({
268
+ ...ctx,
269
+ deliveryQueueId: void 0
270
+ }));
271
+ }
267
272
  };
268
273
  //#endregion
269
274
  export { slackOutbound };