@openclaw/slack 2026.12.2 → 2026.12.6-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/.setup/{action-runtime-zVonj7Ub.mjs → action-runtime-B2JYA0KK.mjs} +30 -39
- package/dist/.setup/action-runtime.runtime-DhTK_A6l.mjs +1 -0
- package/dist/.setup/{actions-0x2TsQH6.mjs → actions-cVgdS6sU.mjs} +147 -22
- package/dist/.setup/{approval-handler.runtime-BBYoz7El.mjs → approval-handler.runtime-DDn3L7Gd.mjs} +5 -5
- package/dist/.setup/{approval-message-updates-BrGg-eis.mjs → approval-message-updates-CnjKG4If.mjs} +1 -1
- package/dist/.setup/{channel-C6-Cp-Fz.mjs → channel-BWLl8hAf.mjs} +24 -28
- package/dist/.setup/{channel-type-BQCZqcgg.mjs → channel-type-CNYPuhN7.mjs} +1 -1
- package/dist/.setup/{channel.setup-Dzt1s8XR.mjs → channel.setup-C0NEy9hG.mjs} +1 -1
- package/dist/.setup/{directory-config-CWeEzb_Y.mjs → directory-config-CFrpmf6d.mjs} +2 -2
- package/dist/.setup/{fork-CiiHD26T.mjs → fork-CyGNd27b.mjs} +3 -3
- package/dist/.setup/{literal-text-DXy7nGRR.mjs → literal-text-D5exd3B9.mjs} +1 -1
- package/dist/.setup/{monitor-D5erEc0i.mjs → monitor-dVQQ8XII.mjs} +264 -150
- package/dist/.setup/{outbound-adapter-BmJCT3Qj.mjs → outbound-adapter-CIJgw3fk.mjs} +6 -6
- package/dist/.setup/{pipeline.runtime-C51V3mhq.mjs → pipeline.runtime-Bet_aK1D.mjs} +53 -37
- package/dist/.setup/{policy-l2IjJV43.mjs → policy-Bo-JJQ2c.mjs} +1 -1
- package/dist/.setup/{probe-DKu67cjh.mjs → probe-DhQ6LeKX.mjs} +70 -12
- package/dist/.setup/{question-delivery-BRQza6lN.mjs → question-delivery-D-WigwxO.mjs} +1 -1
- package/dist/.setup/{relay-source-D2WA09C-.mjs → relay-source-BWKpwdJT.mjs} +2 -2
- package/dist/.setup/{replies-kwdtXt3e.mjs → replies-BFqakO6L.mjs} +6 -6
- package/dist/.setup/{reply-blocks-Cf8e9Sau.mjs → reply-blocks-BsJPukUN.mjs} +28 -6
- package/dist/.setup/{resolve-channels-BoQiIEny.mjs → resolve-channels-Cl7l3BLf.mjs} +1 -1
- package/dist/.setup/{resolve-users-PpJHZiBC.mjs → resolve-users-mep8kUHy.mjs} +1 -1
- package/dist/.setup/{scopes-bvZxH5i3.mjs → scopes-CnMdp9Pj.mjs} +1 -1
- package/dist/.setup/{send-DJpeS70B.mjs → send-kbYZlK6B.mjs} +133 -145
- package/dist/.setup/send-results-DVKN1Zix.mjs +77 -0
- package/dist/.setup/setup-plugin-api-TYFn_irv.mjs +2 -0
- package/dist/.setup/{setup-surface-BqdskNYS.mjs → setup-surface-D8hoExQs.mjs} +3 -3
- package/dist/.setup/slash-dispatch.runtime--T5PbqoB.mjs +7 -0
- package/dist/.setup/{target-parsing-DwYAP3ts.mjs → target-parsing-DaLcdOoQ.mjs} +10 -1
- package/dist/.setup/{targets-eeOxA_b_.mjs → targets-DaKqo4kn.mjs} +1 -1
- package/dist/.source-module-urls/c5ffd0957b234c7c12090e7de4eca2482ef339b8561e078da55b734211b0ba58.json +1 -1
- package/dist/api.js +10 -10
- package/dist/channel-plugin-api.js +1 -1
- package/dist/directory-contract-api.js +1 -1
- package/dist/runtime-api.js +7 -7
- package/dist/setup-entry.js +1 -1
- package/dist/setup-plugin-api.js +1 -1
- package/package.json +4 -4
- package/dist/.setup/action-runtime.runtime-YBV3dNF-.mjs +0 -1
- package/dist/.setup/send-results-Bm6V1ekL.mjs +0 -21
- package/dist/.setup/setup-plugin-api-DPOqeRW0.mjs +0 -2
- package/dist/.setup/slash-dispatch.runtime-CMQgSmJc.mjs +0 -8
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import { i as __exportAll } from "./doctor-contract-CcNdculn.mjs";
|
|
2
2
|
import { f as resolveSlackOperationToken, s as resolveSlackAccount } from "./accounts-Dsl3wabY.mjs";
|
|
3
|
-
import { a as parseSlackTarget, t as canonicalizeSlackApiTargetId } from "./target-parsing-
|
|
4
|
-
import { A as
|
|
3
|
+
import { a as parseSlackTarget, t as canonicalizeSlackApiTargetId } from "./target-parsing-DaLcdOoQ.mjs";
|
|
4
|
+
import { A as truncateSlackTextByUtf8Bytes, Ct as SLACK_TEXT_LIMIT, D as assertSlackDetachedTargetAllowed, St as SLACK_MESSAGE_TEXT_RECOMMENDED_LIMIT, Tt as markdownToSlackMrkdwnChunks, Z as validateSlackBlocksArray, _ as enrichSlackWebApiError, at as hasSlackNativeDataBlock, bt as SLACK_EDIT_TEXT_MAX_BYTES, ct as stripSlackNativeDataBlocks, it as createSlackNativeDataBaseTextConsumer, k as truncateSlackText, nt as buildSlackCompleteBlocksFallbackText, ot as renderSlackBlockFallbackText, rt as buildSlackNativeDataAccessibilityText, st as renderSlackNativeDataPlainTextBlock, v as formatSlackError, wt as chunkSlackMrkdwnText, xt as SLACK_MESSAGE_TEXT_HARD_LIMIT, y as getSlackWebApiErrorData } from "./probe-DhQ6LeKX.mjs";
|
|
5
5
|
import { r as resolveSlackThreadTsValue, t as normalizeSlackThreadTsCandidate } from "./thread-ts-47Au2-Yn.mjs";
|
|
6
6
|
import { c as getSlackWriteClient, f as writeLruMapEntry, i as createSlackTokenCacheKey, l as getOrCreateWeakOwnerMap, n as createSlackReadClient, o as createSlackWriteClient } from "./client-DQqLIemQ.mjs";
|
|
7
|
-
import { t as buildSlackLiteralText } from "./literal-text-
|
|
7
|
+
import { t as buildSlackLiteralText } from "./literal-text-D5exd3B9.mjs";
|
|
8
|
+
import { n as createSlackSendReceiptFromResults, t as annotateSlackPostResult } from "./send-results-DVKN1Zix.mjs";
|
|
8
9
|
import { t as getOptionalSlackRuntime } from "./runtime-C6HKn7Av.mjs";
|
|
9
10
|
import { asOptionalObjectRecord, asOptionalRecord, isRecord, normalizeLowercaseStringOrEmpty, normalizeOptionalString, normalizeTrimmedStringList } from "openclaw/plugin-sdk/string-coerce-runtime";
|
|
10
11
|
import { resolveMarkdownTableMode } from "openclaw/plugin-sdk/markdown-table-runtime";
|
|
@@ -17,130 +18,18 @@ import { createHash, createHmac } from "node:crypto";
|
|
|
17
18
|
import { withTrustedEnvProxyGuardedFetchMode } from "openclaw/plugin-sdk/fetch-runtime";
|
|
18
19
|
import { retryAsync } from "openclaw/plugin-sdk/retry-runtime";
|
|
19
20
|
import { requireRuntimeConfig } from "openclaw/plugin-sdk/plugin-config-runtime";
|
|
20
|
-
import { PlatformMessageNotDispatchedError, extractErrorCode, readErrorName } from "openclaw/plugin-sdk/error-runtime";
|
|
21
|
-
import { readResponseTextLimited } from "openclaw/plugin-sdk/provider-http";
|
|
22
|
-
import { KeyedAsyncQueue } from "openclaw/plugin-sdk/keyed-async-queue";
|
|
23
|
-
import { chunkMarkdownTextWithMode, resolveChunkMode, resolveTextChunkLimit } from "openclaw/plugin-sdk/reply-chunking";
|
|
24
|
-
import { safeEqualSecret } from "openclaw/plugin-sdk/security-runtime";
|
|
25
21
|
import { bufferToBlobPart } from "openclaw/plugin-sdk/blob-runtime";
|
|
22
|
+
import { PlatformMessageNotDispatchedError, extractErrorCode, readErrorName } from "openclaw/plugin-sdk/error-runtime";
|
|
26
23
|
import { buildTimeoutAbortSignal } from "openclaw/plugin-sdk/extension-shared";
|
|
27
24
|
import { extensionForMime } from "openclaw/plugin-sdk/media-mime";
|
|
28
25
|
import { loadOutboundMediaFromUrl } from "openclaw/plugin-sdk/outbound-media";
|
|
29
26
|
import { fetchWithSsrFGuard } from "openclaw/plugin-sdk/ssrf-runtime";
|
|
27
|
+
import { readResponseTextLimited } from "openclaw/plugin-sdk/provider-http";
|
|
28
|
+
import { KeyedAsyncQueue } from "openclaw/plugin-sdk/keyed-async-queue";
|
|
29
|
+
import { chunkMarkdownTextWithMode, resolveChunkMode, resolveTextChunkLimit } from "openclaw/plugin-sdk/reply-chunking";
|
|
30
|
+
import { safeEqualSecret } from "openclaw/plugin-sdk/security-runtime";
|
|
30
31
|
import { createPersistentDedupeCache } from "openclaw/plugin-sdk/dedupe-runtime";
|
|
31
32
|
import { createPluginStateErrorReporter } from "openclaw/plugin-sdk/plugin-state-runtime";
|
|
32
|
-
// extensions/slack/src/native-data-blocks.ts
|
|
33
|
-
const SLACK_RESPONSE_URL_BODY_LIMIT_BYTES = 16384;
|
|
34
|
-
const SLACK_RESPONSE_URL_BODY_TIMEOUT_MS = 3e4;
|
|
35
|
-
/** Match Slack's Web API and response_url `invalid_blocks` error shapes. */
|
|
36
|
-
function isSlackInvalidBlocksError(error) {
|
|
37
|
-
const record = asOptionalRecord(error);
|
|
38
|
-
const rawData = record?.data;
|
|
39
|
-
const data = asOptionalRecord(rawData);
|
|
40
|
-
const rawResponseData = asOptionalRecord(record?.response)?.data;
|
|
41
|
-
const responseData = asOptionalRecord(rawResponseData);
|
|
42
|
-
const code = data?.error ?? (typeof rawData === "string" ? rawData : void 0) ?? responseData?.error ?? (typeof rawResponseData === "string" ? rawResponseData : void 0) ?? record?.error;
|
|
43
|
-
return typeof code === "string" && code.trim().toLowerCase() === "invalid_blocks";
|
|
44
|
-
}
|
|
45
|
-
function isSlackResponseLike(value) {
|
|
46
|
-
const record = asOptionalRecord(value);
|
|
47
|
-
const body = asOptionalRecord(record?.body);
|
|
48
|
-
return typeof record?.status === "number" && (typeof record.arrayBuffer === "function" || typeof body?.getReader === "function");
|
|
49
|
-
}
|
|
50
|
-
/** Consume Bolt 5's native response_url body under strict time and byte bounds. */
|
|
51
|
-
async function isSlackInvalidBlocksResponse(response) {
|
|
52
|
-
if (!isSlackResponseLike(response)) return isSlackInvalidBlocksError(response);
|
|
53
|
-
try {
|
|
54
|
-
const body = await readResponseTextLimited(response, SLACK_RESPONSE_URL_BODY_LIMIT_BYTES, { timeoutMs: SLACK_RESPONSE_URL_BODY_TIMEOUT_MS });
|
|
55
|
-
if (body.trim().toLowerCase() === "invalid_blocks") return true;
|
|
56
|
-
return isSlackInvalidBlocksError(JSON.parse(body));
|
|
57
|
-
} catch {
|
|
58
|
-
return false;
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
/** Bolt 5 omits the response body from RespondError; 400 is contextual here. */
|
|
62
|
-
function isSlackNativeResponseUrlRejection(error) {
|
|
63
|
-
if (isSlackInvalidBlocksError(error)) return true;
|
|
64
|
-
const record = asOptionalRecord(error);
|
|
65
|
-
return record?.code === "slack_bolt_respond_error" && record.statusCode === 400;
|
|
66
|
-
}
|
|
67
|
-
// extensions/slack/src/native-data-fallback.ts
|
|
68
|
-
const SLACK_SECTION_PLAIN_TEXT_MAX = 3e3;
|
|
69
|
-
const SLACK_EMPTY_BLOCK_FALLBACK = "Shared a Block Kit message";
|
|
70
|
-
function chunkSlackTextAtHardLimit(text, limit = SLACK_MESSAGE_TEXT_HARD_LIMIT) {
|
|
71
|
-
if (!text) return [];
|
|
72
|
-
return chunkTextForOutbound(text, Math.max(1, Math.floor(limit)), { preserveWhitespace: true });
|
|
73
|
-
}
|
|
74
|
-
function buildOrderedBlockMessages(params) {
|
|
75
|
-
const messages = [];
|
|
76
|
-
let blocks = [];
|
|
77
|
-
let text = "";
|
|
78
|
-
const flush = () => {
|
|
79
|
-
if (blocks.length === 0) return;
|
|
80
|
-
messages.push({
|
|
81
|
-
text: text || SLACK_EMPTY_BLOCK_FALLBACK,
|
|
82
|
-
blocks,
|
|
83
|
-
mrkdwn: false
|
|
84
|
-
});
|
|
85
|
-
blocks = [];
|
|
86
|
-
text = "";
|
|
87
|
-
};
|
|
88
|
-
const append = (block, entryText = "", continuesText = false) => {
|
|
89
|
-
let nextText = entryText ? `${text}${text && entryText && !continuesText ? "\n\n" : ""}${entryText}` : text;
|
|
90
|
-
if (blocks.length >= 50 || nextText.length > params.textLimit) {
|
|
91
|
-
flush();
|
|
92
|
-
nextText = entryText;
|
|
93
|
-
}
|
|
94
|
-
blocks.push(block);
|
|
95
|
-
text = nextText;
|
|
96
|
-
};
|
|
97
|
-
const appendPlainText = (value) => {
|
|
98
|
-
chunkSlackTextAtHardLimit(value, Math.min(params.textLimit, SLACK_SECTION_PLAIN_TEXT_MAX)).forEach((chunk, index) => {
|
|
99
|
-
append({
|
|
100
|
-
type: "section",
|
|
101
|
-
text: {
|
|
102
|
-
type: "plain_text",
|
|
103
|
-
text: chunk
|
|
104
|
-
}
|
|
105
|
-
}, chunk, index > 0);
|
|
106
|
-
});
|
|
107
|
-
};
|
|
108
|
-
const consumeFromBase = createSlackNativeDataBaseTextConsumer(params.baseText);
|
|
109
|
-
appendPlainText(params.baseText);
|
|
110
|
-
for (const block of params.blocks) {
|
|
111
|
-
if (hasSlackNativeDataBlock([block])) {
|
|
112
|
-
const nativeText = renderSlackNativeDataPlainTextBlock(block)?.trim() || "Slack could not render this chart or table data.";
|
|
113
|
-
if (!consumeFromBase(nativeText)) appendPlainText(nativeText);
|
|
114
|
-
continue;
|
|
115
|
-
}
|
|
116
|
-
append(block, truncateSlackText(renderSlackBlockFallbackText(block, {
|
|
117
|
-
nativeDataFormat: "plain",
|
|
118
|
-
includeSelectOptions: true
|
|
119
|
-
}) ?? "", SLACK_MESSAGE_TEXT_HARD_LIMIT));
|
|
120
|
-
}
|
|
121
|
-
flush();
|
|
122
|
-
return messages;
|
|
123
|
-
}
|
|
124
|
-
/** Build one complete, ordered retry plan after Slack rejects native data blocks. */
|
|
125
|
-
function buildSlackNativeDataDeliveryPlan(params) {
|
|
126
|
-
const baseText = params.baseText?.trim() ?? "";
|
|
127
|
-
const textLimit = Math.min(SLACK_MESSAGE_TEXT_RECOMMENDED_LIMIT, SLACK_MESSAGE_TEXT_HARD_LIMIT, Math.max(1, Math.floor(params.textLimit ?? 4e4)));
|
|
128
|
-
const hasNativeData = hasSlackNativeDataBlock(params.blocks);
|
|
129
|
-
const accessibilityText = buildSlackNativeDataAccessibilityText(baseText, params.blocks) || (hasNativeData ? "Slack could not render this chart or table data." : SLACK_EMPTY_BLOCK_FALLBACK);
|
|
130
|
-
const fallbackMessages = stripSlackNativeDataBlocks(params.blocks).length === 0 ? chunkSlackTextAtHardLimit(accessibilityText, textLimit).map((text) => ({
|
|
131
|
-
text,
|
|
132
|
-
mrkdwn: false
|
|
133
|
-
})) : buildOrderedBlockMessages({
|
|
134
|
-
baseText,
|
|
135
|
-
blocks: params.blocks,
|
|
136
|
-
textLimit
|
|
137
|
-
});
|
|
138
|
-
return {
|
|
139
|
-
accessibilityText: truncateSlackText(accessibilityText, SLACK_MESSAGE_TEXT_HARD_LIMIT),
|
|
140
|
-
fallbackMessages,
|
|
141
|
-
skipOriginalBlocks: accessibilityText.length > SLACK_MESSAGE_TEXT_HARD_LIMIT
|
|
142
|
-
};
|
|
143
|
-
}
|
|
144
33
|
// extensions/slack/src/post-message-identity.ts
|
|
145
34
|
function buildSlackMessageIdentityPayload(identity) {
|
|
146
35
|
return {
|
|
@@ -291,6 +180,9 @@ function classifySlackCustomIdentityError(err) {
|
|
|
291
180
|
if (normalizeLowercaseStringOrEmpty(data?.needed).includes("chat:write.customize")) return "scope";
|
|
292
181
|
return [...normalizeTrimmedStringList(data?.response_metadata?.scopes), ...normalizeTrimmedStringList(data?.response_metadata?.acceptedScopes)].map((scope) => normalizeLowercaseStringOrEmpty(scope)).includes("chat:write.customize") ? "scope" : void 0;
|
|
293
182
|
}
|
|
183
|
+
function slackComparisonText(accepted, rendered, sourceMarkdown) {
|
|
184
|
+
return accepted === rendered ? sourceMarkdown ?? accepted : accepted;
|
|
185
|
+
}
|
|
294
186
|
async function postSlackMessageBestEffort(params) {
|
|
295
187
|
const threadPayload = params.replyBroadcast && params.threadTs ? {
|
|
296
188
|
thread_ts: params.threadTs,
|
|
@@ -340,8 +232,10 @@ async function postSlackMessageBestEffort(params) {
|
|
|
340
232
|
}
|
|
341
233
|
})();
|
|
342
234
|
const timestamp = requireSlackPostMessageTimestamp(posted.response);
|
|
235
|
+
const acceptedText = posted.response.message?.text ?? basePayload.text;
|
|
343
236
|
return {
|
|
344
237
|
...posted,
|
|
238
|
+
comparisonText: slackComparisonText(acceptedText, basePayload.text, params.replyBroadcast ? params.sourceMarkdown : void 0),
|
|
345
239
|
response: {
|
|
346
240
|
...posted.response,
|
|
347
241
|
ts: timestamp
|
|
@@ -415,6 +309,118 @@ async function uploadSlackFile(params) {
|
|
|
415
309
|
if (!completeResp.ok) throw new Error(`Failed to complete upload: ${completeResp.error ?? "unknown error"}`);
|
|
416
310
|
return uploadFileId;
|
|
417
311
|
}
|
|
312
|
+
// extensions/slack/src/native-data-blocks.ts
|
|
313
|
+
const SLACK_RESPONSE_URL_BODY_LIMIT_BYTES = 16384;
|
|
314
|
+
const SLACK_RESPONSE_URL_BODY_TIMEOUT_MS = 3e4;
|
|
315
|
+
/** Match Slack's Web API and response_url `invalid_blocks` error shapes. */
|
|
316
|
+
function isSlackInvalidBlocksError(error) {
|
|
317
|
+
const record = asOptionalRecord(error);
|
|
318
|
+
const rawData = record?.data;
|
|
319
|
+
const data = asOptionalRecord(rawData);
|
|
320
|
+
const rawResponseData = asOptionalRecord(record?.response)?.data;
|
|
321
|
+
const responseData = asOptionalRecord(rawResponseData);
|
|
322
|
+
const code = data?.error ?? (typeof rawData === "string" ? rawData : void 0) ?? responseData?.error ?? (typeof rawResponseData === "string" ? rawResponseData : void 0) ?? record?.error;
|
|
323
|
+
return typeof code === "string" && code.trim().toLowerCase() === "invalid_blocks";
|
|
324
|
+
}
|
|
325
|
+
function isSlackResponseLike(value) {
|
|
326
|
+
const record = asOptionalRecord(value);
|
|
327
|
+
const body = asOptionalRecord(record?.body);
|
|
328
|
+
return typeof record?.status === "number" && (typeof record.arrayBuffer === "function" || typeof body?.getReader === "function");
|
|
329
|
+
}
|
|
330
|
+
/** Consume Bolt 5's native response_url body under strict time and byte bounds. */
|
|
331
|
+
async function isSlackInvalidBlocksResponse(response) {
|
|
332
|
+
if (!isSlackResponseLike(response)) return isSlackInvalidBlocksError(response);
|
|
333
|
+
try {
|
|
334
|
+
const body = await readResponseTextLimited(response, SLACK_RESPONSE_URL_BODY_LIMIT_BYTES, { timeoutMs: SLACK_RESPONSE_URL_BODY_TIMEOUT_MS });
|
|
335
|
+
if (body.trim().toLowerCase() === "invalid_blocks") return true;
|
|
336
|
+
return isSlackInvalidBlocksError(JSON.parse(body));
|
|
337
|
+
} catch {
|
|
338
|
+
return false;
|
|
339
|
+
}
|
|
340
|
+
}
|
|
341
|
+
/** Bolt 5 omits the response body from RespondError; 400 is contextual here. */
|
|
342
|
+
function isSlackNativeResponseUrlRejection(error) {
|
|
343
|
+
if (isSlackInvalidBlocksError(error)) return true;
|
|
344
|
+
const record = asOptionalRecord(error);
|
|
345
|
+
return record?.code === "slack_bolt_respond_error" && record.statusCode === 400;
|
|
346
|
+
}
|
|
347
|
+
// extensions/slack/src/native-data-fallback.ts
|
|
348
|
+
const SLACK_SECTION_PLAIN_TEXT_MAX = 3e3;
|
|
349
|
+
const SLACK_EMPTY_BLOCK_FALLBACK = "Shared a Block Kit message";
|
|
350
|
+
function chunkSlackTextAtHardLimit(text, limit = SLACK_MESSAGE_TEXT_HARD_LIMIT) {
|
|
351
|
+
if (!text) return [];
|
|
352
|
+
return chunkTextForOutbound(text, Math.max(1, Math.floor(limit)), { preserveWhitespace: true });
|
|
353
|
+
}
|
|
354
|
+
function buildOrderedBlockMessages(params) {
|
|
355
|
+
const messages = [];
|
|
356
|
+
let blocks = [];
|
|
357
|
+
let text = "";
|
|
358
|
+
const flush = () => {
|
|
359
|
+
if (blocks.length === 0) return;
|
|
360
|
+
messages.push({
|
|
361
|
+
text: text || SLACK_EMPTY_BLOCK_FALLBACK,
|
|
362
|
+
blocks,
|
|
363
|
+
mrkdwn: false
|
|
364
|
+
});
|
|
365
|
+
blocks = [];
|
|
366
|
+
text = "";
|
|
367
|
+
};
|
|
368
|
+
const append = (block, entryText = "", continuesText = false) => {
|
|
369
|
+
let nextText = entryText ? `${text}${text && entryText && !continuesText ? "\n\n" : ""}${entryText}` : text;
|
|
370
|
+
if (blocks.length >= 50 || nextText.length > params.textLimit) {
|
|
371
|
+
flush();
|
|
372
|
+
nextText = entryText;
|
|
373
|
+
}
|
|
374
|
+
blocks.push(block);
|
|
375
|
+
text = nextText;
|
|
376
|
+
};
|
|
377
|
+
const appendPlainText = (value) => {
|
|
378
|
+
chunkSlackTextAtHardLimit(value, Math.min(params.textLimit, SLACK_SECTION_PLAIN_TEXT_MAX)).forEach((chunk, index) => {
|
|
379
|
+
append({
|
|
380
|
+
type: "section",
|
|
381
|
+
text: {
|
|
382
|
+
type: "plain_text",
|
|
383
|
+
text: chunk
|
|
384
|
+
}
|
|
385
|
+
}, chunk, index > 0);
|
|
386
|
+
});
|
|
387
|
+
};
|
|
388
|
+
const consumeFromBase = createSlackNativeDataBaseTextConsumer(params.baseText);
|
|
389
|
+
appendPlainText(params.baseText);
|
|
390
|
+
for (const block of params.blocks) {
|
|
391
|
+
if (hasSlackNativeDataBlock([block])) {
|
|
392
|
+
const nativeText = renderSlackNativeDataPlainTextBlock(block)?.trim() || "Slack could not render this chart or table data.";
|
|
393
|
+
if (!consumeFromBase(nativeText)) appendPlainText(nativeText);
|
|
394
|
+
continue;
|
|
395
|
+
}
|
|
396
|
+
append(block, truncateSlackText(renderSlackBlockFallbackText(block, {
|
|
397
|
+
nativeDataFormat: "plain",
|
|
398
|
+
includeSelectOptions: true
|
|
399
|
+
}) ?? "", SLACK_MESSAGE_TEXT_HARD_LIMIT));
|
|
400
|
+
}
|
|
401
|
+
flush();
|
|
402
|
+
return messages;
|
|
403
|
+
}
|
|
404
|
+
/** Build one complete, ordered retry plan after Slack rejects native data blocks. */
|
|
405
|
+
function buildSlackNativeDataDeliveryPlan(params) {
|
|
406
|
+
const baseText = params.baseText?.trim() ?? "";
|
|
407
|
+
const textLimit = Math.min(SLACK_MESSAGE_TEXT_RECOMMENDED_LIMIT, SLACK_MESSAGE_TEXT_HARD_LIMIT, Math.max(1, Math.floor(params.textLimit ?? 4e4)));
|
|
408
|
+
const hasNativeData = hasSlackNativeDataBlock(params.blocks);
|
|
409
|
+
const accessibilityText = buildSlackNativeDataAccessibilityText(baseText, params.blocks) || (hasNativeData ? "Slack could not render this chart or table data." : SLACK_EMPTY_BLOCK_FALLBACK);
|
|
410
|
+
const fallbackMessages = stripSlackNativeDataBlocks(params.blocks).length === 0 ? chunkSlackTextAtHardLimit(accessibilityText, textLimit).map((text) => ({
|
|
411
|
+
text,
|
|
412
|
+
mrkdwn: false
|
|
413
|
+
})) : buildOrderedBlockMessages({
|
|
414
|
+
baseText,
|
|
415
|
+
blocks: params.blocks,
|
|
416
|
+
textLimit
|
|
417
|
+
});
|
|
418
|
+
return {
|
|
419
|
+
accessibilityText: truncateSlackText(accessibilityText, SLACK_MESSAGE_TEXT_HARD_LIMIT),
|
|
420
|
+
fallbackMessages,
|
|
421
|
+
skipOriginalBlocks: accessibilityText.length > SLACK_MESSAGE_TEXT_HARD_LIMIT
|
|
422
|
+
};
|
|
423
|
+
}
|
|
418
424
|
// extensions/slack/src/sent-thread-cache.ts
|
|
419
425
|
/**
|
|
420
426
|
* Cache of Slack threads the bot has participated in.
|
|
@@ -580,18 +586,6 @@ function createSlackSendReceipt(params) {
|
|
|
580
586
|
threadId: params.threadTs
|
|
581
587
|
});
|
|
582
588
|
}
|
|
583
|
-
function createSlackSendReceiptFromResults(results, threadTs) {
|
|
584
|
-
const receipt = createMessageReceiptFromOutboundResults({
|
|
585
|
-
results,
|
|
586
|
-
threadId: threadTs
|
|
587
|
-
});
|
|
588
|
-
const thread = threadTs ? { threadId: threadTs } : {};
|
|
589
|
-
for (const [index, part] of receipt.parts.entries()) Object.assign(part, {
|
|
590
|
-
index,
|
|
591
|
-
...thread
|
|
592
|
-
});
|
|
593
|
-
return Object.assign(receipt, thread);
|
|
594
|
-
}
|
|
595
589
|
function createSlackSendResult(messageId, channelId, kind, threadTs) {
|
|
596
590
|
return {
|
|
597
591
|
messageId,
|
|
@@ -937,16 +931,8 @@ async function sendMessageSlack(to, message, options) {
|
|
|
937
931
|
...delivery.dmCacheOwner ? { dmCacheOwner: delivery.dmCacheOwner } : {}
|
|
938
932
|
});
|
|
939
933
|
const deliveredResults = [];
|
|
940
|
-
const reportDelivery = async (result, deliveredBlocks) => {
|
|
941
|
-
const
|
|
942
|
-
const deliveryResult = slackQuestionActionIds.length ? {
|
|
943
|
-
...result,
|
|
944
|
-
meta: {
|
|
945
|
-
...result.meta,
|
|
946
|
-
slackQuestionActionIds,
|
|
947
|
-
[SLACK_QUESTION_FINALIZATION_BLOCKS]: deliveredBlocks
|
|
948
|
-
}
|
|
949
|
-
} : result;
|
|
934
|
+
const reportDelivery = async (result, deliveredBlocks, acceptedText) => {
|
|
935
|
+
const deliveryResult = annotateSlackPostResult(result, delivery.teamId, deliveredBlocks, acceptedText);
|
|
950
936
|
deliveredResults.push(deliveryResult);
|
|
951
937
|
await opts.onDeliveryResult?.(deliveryResult);
|
|
952
938
|
return deliveryResult;
|
|
@@ -986,10 +972,11 @@ async function sendMessageSlack(to, message, options) {
|
|
|
986
972
|
const { response } = posted;
|
|
987
973
|
sendIdentity = posted.identity;
|
|
988
974
|
lastMessageId = response.ts;
|
|
989
|
-
|
|
975
|
+
const confirmedChannelId = normalizeOptionalString(response.channel);
|
|
976
|
+
deliveredChannelId = confirmedChannelId ?? deliveredChannelId;
|
|
990
977
|
const responseThreadTs = resolvePostedMessageThreadTs(response);
|
|
991
978
|
canonicalDeliveredThreadTs ??= responseThreadTs;
|
|
992
|
-
return await reportDelivery(createSlackSendResult(response.ts, deliveredChannelId, part.blocks ? "card" : "text", responseThreadTs ?? normalizeSlackThreadTsCandidate(opts.threadTs)), part.blocks);
|
|
979
|
+
return await reportDelivery(createSlackSendResult(response.ts, deliveredChannelId, part.blocks ? "card" : "text", responseThreadTs ?? normalizeSlackThreadTsCandidate(opts.threadTs)), part.blocks, confirmedChannelId ? blocks || opts.mediaUrl ? "" : posted.comparisonText : void 0);
|
|
993
980
|
};
|
|
994
981
|
if (blocks && opts.mediaUrl) throw new Error("Slack send does not support blocks with mediaUrl");
|
|
995
982
|
if (blocks) {
|
|
@@ -1084,6 +1071,7 @@ async function sendMessageSlack(to, message, options) {
|
|
|
1084
1071
|
const partDelivery = await postPart({
|
|
1085
1072
|
...part,
|
|
1086
1073
|
replyBroadcast: carriesPrimaryMessageOptions ? opts.replyBroadcast : void 0,
|
|
1074
|
+
sourceMarkdown: messages.length === 1 ? trimmedMessage : void 0,
|
|
1087
1075
|
metadata
|
|
1088
1076
|
});
|
|
1089
1077
|
if (pendingBlockFallback && partDelivery.meta?.slackQuestionActionIds.length) questionDelivery = partDelivery;
|
|
@@ -1107,4 +1095,4 @@ async function sendMessageSlack(to, message, options) {
|
|
|
1107
1095
|
if (threadTs && sent.channelId && account.accountId) recordSlackThreadParticipation(account.accountId, sent.channelId, threadTs, { teamId: delivery.teamId });
|
|
1108
1096
|
return sent;
|
|
1109
1097
|
}
|
|
1110
|
-
export {
|
|
1098
|
+
export { requireSlackPostMessageTimestamp as _, clearSlackThreadFailureNotice as a, hasSlackMessageIdentity as b, hasSlackThreadParticipation as c, recordSlackThreadParticipation as d, buildSlackNativeDataDeliveryPlan as f, isSlackNativeResponseUrlRejection as g, isSlackInvalidBlocksResponse as h, updateMessageSlack as i, hasSlackThreadParticipationWithPersistence as l, isSlackInvalidBlocksError as m, send_exports as n, clearSlackThreadParticipationCache as o, chunkSlackTextAtHardLimit as p, setSlackDefaultSendIdentity as r, hasSlackThreadFailureNotice as s, sendMessageSlack as t, recordSlackThreadFailureNotice as u, slackComparisonText as v, buildSlackMessageIdentityPayload as y };
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import { H as resolveSlackQuestionActionIds, M as SLACK_QUESTION_FINALIZATION_BLOCKS } from "./probe-DhQ6LeKX.mjs";
|
|
2
|
+
import { createMessageReceiptFromOutboundResults } from "openclaw/plugin-sdk/channel-outbound";
|
|
3
|
+
import { jsonResult } from "openclaw/plugin-sdk/tool-results";
|
|
4
|
+
// extensions/slack/src/send-results.ts
|
|
5
|
+
const teamKey = Symbol.for("openclaw.messageAction.teamId");
|
|
6
|
+
const acceptedTextKey = Symbol("slack.acceptedPostText");
|
|
7
|
+
/** Retain the physical post's scope and controls before reporting or merging its delivery. */
|
|
8
|
+
function annotateSlackPostResult(result, teamId, blocks, acceptedText) {
|
|
9
|
+
const parts = result.receipt.parts;
|
|
10
|
+
for (const part of parts) {
|
|
11
|
+
if (teamId) part[teamKey] = teamId;
|
|
12
|
+
if (acceptedText !== void 0) part[acceptedTextKey] = acceptedText;
|
|
13
|
+
}
|
|
14
|
+
const slackQuestionActionIds = resolveSlackQuestionActionIds(blocks);
|
|
15
|
+
return slackQuestionActionIds.length ? {
|
|
16
|
+
...result,
|
|
17
|
+
meta: {
|
|
18
|
+
...result.meta,
|
|
19
|
+
slackQuestionActionIds,
|
|
20
|
+
[SLACK_QUESTION_FINALIZATION_BLOCKS]: blocks
|
|
21
|
+
}
|
|
22
|
+
} : result;
|
|
23
|
+
}
|
|
24
|
+
function slackActionSendResult(results) {
|
|
25
|
+
const result = mergeSlackSendResults(results);
|
|
26
|
+
const parts = result.receipt?.parts ?? [];
|
|
27
|
+
const first = parts[0];
|
|
28
|
+
const channelId = first?.raw?.channelId;
|
|
29
|
+
const teamId = first?.[teamKey]?.toUpperCase();
|
|
30
|
+
const sameRoute = channelId && results.every((r) => r.receipt?.parts.length) && parts.every((part) => part.raw?.channelId === channelId && part[teamKey]?.toUpperCase() === teamId && part[acceptedTextKey] !== void 0);
|
|
31
|
+
return Object.assign(jsonResult({
|
|
32
|
+
ok: true,
|
|
33
|
+
result
|
|
34
|
+
}), { [Symbol.for("openclaw.messageAction.sentPost")]: {
|
|
35
|
+
channelId: sameRoute ? channelId : "",
|
|
36
|
+
...sameRoute && teamId ? { teamId } : {},
|
|
37
|
+
messageIds: sameRoute ? result.receipt.platformMessageIds : [],
|
|
38
|
+
text: sameRoute && parts.length === 1 ? first?.[acceptedTextKey] ?? "" : ""
|
|
39
|
+
} });
|
|
40
|
+
}
|
|
41
|
+
function slackPostMutationResult(target, accountId, messageId, text) {
|
|
42
|
+
return Object.assign(jsonResult({ ok: true }), { [Symbol.for("openclaw.messageAction.appliedMutation")]: {
|
|
43
|
+
channelId: target.channelId,
|
|
44
|
+
teamId: target.teamId?.toUpperCase(),
|
|
45
|
+
accountId,
|
|
46
|
+
messageId,
|
|
47
|
+
...text === void 0 ? {} : { text }
|
|
48
|
+
} });
|
|
49
|
+
}
|
|
50
|
+
function createSlackSendReceiptFromResults(results, threadTs) {
|
|
51
|
+
const receipt = createMessageReceiptFromOutboundResults({
|
|
52
|
+
results,
|
|
53
|
+
threadId: threadTs
|
|
54
|
+
});
|
|
55
|
+
const thread = threadTs ? { threadId: threadTs } : {};
|
|
56
|
+
for (const [index, part] of receipt.parts.entries()) Object.assign(part, {
|
|
57
|
+
index,
|
|
58
|
+
...thread
|
|
59
|
+
});
|
|
60
|
+
return Object.assign(receipt, thread);
|
|
61
|
+
}
|
|
62
|
+
function mergeSlackSendResults(results) {
|
|
63
|
+
const lastResult = results.at(-1);
|
|
64
|
+
if (!lastResult) throw new Error("Slack send plan produced no delivery.");
|
|
65
|
+
if (results.length === 1) return lastResult;
|
|
66
|
+
const receipt = createSlackSendReceiptFromResults(results);
|
|
67
|
+
const questionResult = results.find((result) => result.meta?.slackQuestionActionIds.length);
|
|
68
|
+
return {
|
|
69
|
+
...lastResult,
|
|
70
|
+
receipt,
|
|
71
|
+
...questionResult?.meta ? { meta: {
|
|
72
|
+
...questionResult.meta,
|
|
73
|
+
slackQuestionMessageId: questionResult.meta.slackQuestionMessageId ?? questionResult.messageId
|
|
74
|
+
} } : {}
|
|
75
|
+
};
|
|
76
|
+
}
|
|
77
|
+
export { slackPostMutationResult as a, slackActionSendResult as i, createSlackSendReceiptFromResults as n, mergeSlackSendResults as r, annotateSlackPostResult as t };
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { c as resolveSlackAccountAllowFrom, o as resolveDefaultSlackAccountId } from "./accounts-Dsl3wabY.mjs";
|
|
2
2
|
import { t as inspectSlackAccount } from "./account-inspect-Cvn3f95c.mjs";
|
|
3
|
-
import { a as buildSlackAllowFromPrompt, i as SLACK_CHANNEL, n as createSlackSetupWizardBase } from "./channel.setup-
|
|
4
|
-
import { t as resolveSlackChannelAllowlist } from "./resolve-channels-
|
|
5
|
-
import { t as resolveSlackUserAllowlist } from "./resolve-users-
|
|
3
|
+
import { a as buildSlackAllowFromPrompt, i as SLACK_CHANNEL, n as createSlackSetupWizardBase } from "./channel.setup-C0NEy9hG.mjs";
|
|
4
|
+
import { t as resolveSlackChannelAllowlist } from "./resolve-channels-Cl7l3BLf.mjs";
|
|
5
|
+
import { t as resolveSlackUserAllowlist } from "./resolve-users-mep8kUHy.mjs";
|
|
6
6
|
import { normalizeStringEntries } from "openclaw/plugin-sdk/string-coerce-runtime";
|
|
7
7
|
import { resolveBasicAllowFromEntries } from "openclaw/plugin-sdk/allow-from";
|
|
8
8
|
import { createSetupTranslator, noteChannelLookupFailure, noteChannelLookupSummary, patchChannelConfigForAccount, promptResolvedAllowFrom, resolveEntriesWithOptionalToken, resolveSetupAccountId, splitSetupEntries } from "openclaw/plugin-sdk/setup-runtime";
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { i as sanitizeSlackMonitorReplyPayload, r as deliverSlackSlashReplies } from "./replies-BFqakO6L.mjs";
|
|
2
|
+
import { resolveMarkdownTableMode } from "openclaw/plugin-sdk/markdown-table-runtime";
|
|
3
|
+
import { resolveAgentRoute } from "openclaw/plugin-sdk/routing";
|
|
4
|
+
import { buildChannelInboundEventContext, dispatchChannelInboundTurn, isChannelPartialDeliveryError } from "openclaw/plugin-sdk/channel-inbound";
|
|
5
|
+
import { resolveChunkMode } from "openclaw/plugin-sdk/reply-runtime";
|
|
6
|
+
import { recordDeliveredCommandExchange } from "openclaw/plugin-sdk/session-transcript-runtime";
|
|
7
|
+
export { buildChannelInboundEventContext, deliverSlackSlashReplies, dispatchChannelInboundTurn, isChannelPartialDeliveryError, recordDeliveredCommandExchange, resolveAgentRoute, resolveChunkMode, resolveMarkdownTableMode, sanitizeSlackMonitorReplyPayload };
|
|
@@ -114,6 +114,15 @@ function resolveSlackChannelId(raw) {
|
|
|
114
114
|
function normalizeSlackMessagingTarget(raw) {
|
|
115
115
|
return parseSlackTarget(raw, { defaultKind: "channel" })?.normalized;
|
|
116
116
|
}
|
|
117
|
+
/** Session and delivery identities stay folded; Slack API boundaries restore ID casing. */
|
|
118
|
+
function resolveSlackDeliveryTarget(params) {
|
|
119
|
+
const parent = params.parentConversationId?.trim();
|
|
120
|
+
const child = params.conversationId.trim();
|
|
121
|
+
return parent && parent !== child ? {
|
|
122
|
+
to: normalizeSlackMessagingTarget(parent),
|
|
123
|
+
threadId: child
|
|
124
|
+
} : { to: normalizeSlackMessagingTarget(child) };
|
|
125
|
+
}
|
|
117
126
|
function slackTargetsMatch(left, right) {
|
|
118
127
|
const leftTarget = normalizeSlackMessagingTarget(left);
|
|
119
128
|
const rightTarget = normalizeSlackMessagingTarget(right);
|
|
@@ -123,4 +132,4 @@ function looksLikeSlackTargetId(raw) {
|
|
|
123
132
|
const trimmed = raw.trim();
|
|
124
133
|
return /^<@([A-Z0-9]+)>$/i.test(trimmed) || /^(user|channel):/i.test(trimmed) || /^slack:/i.test(trimmed) || /^team:/i.test(trimmed) || /^[@#]/.test(trimmed) || /^[CUWGD][A-Z0-9]{8,}$/i.test(trimmed);
|
|
125
134
|
}
|
|
126
|
-
export { parseSlackTarget as a,
|
|
135
|
+
export { parseSlackTarget as a, resolveWorkspaceQualifiedSlackTarget as c, normalizeSlackMessagingTarget as i, slackTargetsMatch as l, formatSlackTarget as n, resolveSlackChannelId as o, looksLikeSlackTargetId as r, resolveSlackDeliveryTarget as s, canonicalizeSlackApiTargetId as t };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { a as parseSlackTarget,
|
|
1
|
+
import { a as parseSlackTarget, l as slackTargetsMatch } from "./target-parsing-DaLcdOoQ.mjs";
|
|
2
2
|
// extensions/slack/src/targets.ts
|
|
3
3
|
function matchesResolvedUserTarget(target, currentMessagingTarget) {
|
|
4
4
|
const resolvedId = target.trim();
|