@openclaw/slack 2026.8.1-beta.3 → 2026.8.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-configured-sUohAxZr.js +33 -0
- package/dist/account-inspect-CN2hBsim.js +87 -0
- package/dist/account-inspect-api.js +1 -1
- package/dist/{accounts-BlzxuYle.js → accounts-Dm_H77gH.js} +7 -10
- package/dist/{accounts.runtime-CbabBL8x.js → accounts.runtime-DRuEK6mL.js} +1 -1
- package/dist/{action-runtime-D6jg2CQd.js → action-runtime-044ldvNL.js} +53 -48
- package/dist/action-runtime.runtime-BL3KzX13.js +2 -0
- package/dist/{actions-DFk0ANVB.js → actions-BI7JkfVm.js} +266 -96
- package/dist/api.js +12 -12
- package/dist/{approval-handler.runtime-BNvAoKdK.js → approval-handler.runtime-DYv0UIZS.js} +53 -176
- package/dist/{channel-CA5w7qDF.js → channel-1vIJOzPx.js} +77 -142
- package/dist/channel-config-api.js +1 -1
- package/dist/channel-plugin-api.js +1 -1
- package/dist/{channel-type-CZWv55Wu.js → channel-type-DlFSKeIZ.js} +3 -3
- package/dist/{channel.setup-CpyYsEXH.js → channel.setup-ofDi3_Pu.js} +34 -49
- package/dist/{config-schema-CN3XZRX5.js → config-schema-BVIMyiDN.js} +19 -12
- package/dist/configured-state.js +34 -0
- package/dist/{directory-config-BGYyuzWh.js → directory-config-DqfQ42OV.js} +1 -1
- package/dist/directory-contract-api.js +1 -1
- package/dist/{directory-live-DjUJQLbq.js → directory-live-BPaNHjmP.js} +2 -2
- package/dist/{group-policy-DyfB_ZIE.js → group-policy-BdwszjYn.js} +581 -743
- package/dist/{message-tool-api-CqMr5Rmc.js → message-tool-api-CJ0kjcg5.js} +23 -5
- package/dist/message-tool-api.js +1 -1
- package/dist/{monitor-Chrecrb9.js → monitor-Dq5Cmrvp.js} +3 -3
- package/dist/{outbound-adapter-DuRqAQXK.js → outbound-adapter-DYaI8ThX.js} +93 -68
- package/dist/{pipeline.runtime-Bbfd5VFW.js → pipeline.runtime-Bd22U0ga.js} +128 -160
- package/dist/{policy-BKXSxrIS.js → policy-CtQVbde1.js} +2 -1
- package/dist/{probe-BVA65leh.js → probe-0usmAb0i.js} +209 -22
- package/dist/{provider-CUUiwsg2.js → provider-CN_8hFv2.js} +243 -146
- package/dist/{relay-source-mhpMMRG-.js → relay-source-BNGpsdwV.js} +1 -1
- package/dist/{replies-SnWyXcsL.js → replies-BSiRQOJ1.js} +15 -5
- package/dist/{resolve-channels-BSpqC8jU.js → resolve-channels-Czheznc8.js} +1 -1
- package/dist/{resolve-users-Dvz9pDe0.js → resolve-users-BAOlNimr.js} +1 -1
- package/dist/runtime-api.js +11 -11
- package/dist/{scopes-BSk4GZvZ.js → scopes-COSlmhnH.js} +1 -1
- package/dist/{send-CtnOxKCc.js → send-DS9ICrBI.js} +39 -31
- package/dist/send-results-eeOu_HYm.js +23 -0
- package/dist/{send.runtime-kYctMHSd.js → send.runtime-D_Bb6IuH.js} +1 -1
- package/dist/setup-plugin-api.js +1 -1
- package/dist/{setup-surface-BPFfp6So.js → setup-surface-BGnd2pSe.js} +6 -6
- package/dist/{shared-DJBaslN7.js → shared-D5B-5hBg.js} +26 -6
- package/dist/{slash-dispatch.runtime-Cf2FTrnf.js → slash-dispatch.runtime-CilDmI0c.js} +3 -3
- package/node_modules/@slack/bolt/node_modules/@types/node/README.md +1 -1
- package/node_modules/@slack/bolt/node_modules/@types/node/child_process.d.ts +0 -1
- package/node_modules/@slack/bolt/node_modules/@types/node/crypto.d.ts +6 -6
- package/node_modules/@slack/bolt/node_modules/@types/node/dns/promises.d.ts +5 -5
- package/node_modules/@slack/bolt/node_modules/@types/node/dns.d.ts +5 -5
- package/node_modules/@slack/bolt/node_modules/@types/node/fs.d.ts +7 -0
- package/node_modules/@slack/bolt/node_modules/@types/node/http.d.ts +30 -0
- package/node_modules/@slack/bolt/node_modules/@types/node/http2.d.ts +4 -4
- package/node_modules/@slack/bolt/node_modules/@types/node/os.d.ts +30 -30
- package/node_modules/@slack/bolt/node_modules/@types/node/package.json +2 -2
- package/node_modules/@slack/bolt/node_modules/@types/node/perf_hooks.d.ts +2 -1
- package/node_modules/@slack/bolt/node_modules/@types/node/process.d.ts +42 -43
- package/node_modules/@slack/bolt/node_modules/@types/node/quic.d.ts +1049 -84
- package/node_modules/@slack/bolt/node_modules/@types/node/sqlite.d.ts +14 -1
- package/node_modules/@slack/bolt/node_modules/@types/node/stream/iter.d.ts +3 -2
- package/node_modules/@slack/bolt/node_modules/@types/node/test.d.ts +61 -0
- package/node_modules/@slack/bolt/node_modules/@types/node/v8.d.ts +20 -23
- package/node_modules/@slack/bolt/node_modules/body-parser/node_modules/content-type/README.md +2 -0
- package/node_modules/@slack/bolt/node_modules/body-parser/node_modules/content-type/dist/index.d.ts +20 -0
- package/node_modules/@slack/bolt/node_modules/body-parser/node_modules/content-type/dist/index.js +20 -14
- package/node_modules/@slack/bolt/node_modules/body-parser/node_modules/content-type/dist/index.js.map +1 -1
- package/node_modules/@slack/bolt/node_modules/body-parser/node_modules/content-type/package.json +1 -1
- package/node_modules/@slack/bolt/node_modules/type-is/node_modules/content-type/README.md +2 -0
- package/node_modules/@slack/bolt/node_modules/type-is/node_modules/content-type/dist/index.d.ts +20 -0
- package/node_modules/@slack/bolt/node_modules/type-is/node_modules/content-type/dist/index.js +20 -14
- package/node_modules/@slack/bolt/node_modules/type-is/node_modules/content-type/dist/index.js.map +1 -1
- package/node_modules/@slack/bolt/node_modules/type-is/node_modules/content-type/package.json +1 -1
- package/node_modules/@slack/socket-mode/node_modules/@types/node/README.md +1 -1
- package/node_modules/@slack/socket-mode/node_modules/@types/node/child_process.d.ts +0 -1
- package/node_modules/@slack/socket-mode/node_modules/@types/node/crypto.d.ts +6 -6
- package/node_modules/@slack/socket-mode/node_modules/@types/node/dns/promises.d.ts +5 -5
- package/node_modules/@slack/socket-mode/node_modules/@types/node/dns.d.ts +5 -5
- package/node_modules/@slack/socket-mode/node_modules/@types/node/fs.d.ts +7 -0
- package/node_modules/@slack/socket-mode/node_modules/@types/node/http.d.ts +30 -0
- package/node_modules/@slack/socket-mode/node_modules/@types/node/http2.d.ts +4 -4
- package/node_modules/@slack/socket-mode/node_modules/@types/node/os.d.ts +30 -30
- package/node_modules/@slack/socket-mode/node_modules/@types/node/package.json +2 -2
- package/node_modules/@slack/socket-mode/node_modules/@types/node/perf_hooks.d.ts +2 -1
- package/node_modules/@slack/socket-mode/node_modules/@types/node/process.d.ts +42 -43
- package/node_modules/@slack/socket-mode/node_modules/@types/node/quic.d.ts +1049 -84
- package/node_modules/@slack/socket-mode/node_modules/@types/node/sqlite.d.ts +14 -1
- package/node_modules/@slack/socket-mode/node_modules/@types/node/stream/iter.d.ts +3 -2
- package/node_modules/@slack/socket-mode/node_modules/@types/node/test.d.ts +61 -0
- package/node_modules/@slack/socket-mode/node_modules/@types/node/v8.d.ts +20 -23
- package/node_modules/@slack/web-api/node_modules/@types/node/README.md +1 -1
- package/node_modules/@slack/web-api/node_modules/@types/node/child_process.d.ts +0 -1
- package/node_modules/@slack/web-api/node_modules/@types/node/crypto.d.ts +6 -6
- package/node_modules/@slack/web-api/node_modules/@types/node/dns/promises.d.ts +5 -5
- package/node_modules/@slack/web-api/node_modules/@types/node/dns.d.ts +5 -5
- package/node_modules/@slack/web-api/node_modules/@types/node/fs.d.ts +7 -0
- package/node_modules/@slack/web-api/node_modules/@types/node/http.d.ts +30 -0
- package/node_modules/@slack/web-api/node_modules/@types/node/http2.d.ts +4 -4
- package/node_modules/@slack/web-api/node_modules/@types/node/os.d.ts +30 -30
- package/node_modules/@slack/web-api/node_modules/@types/node/package.json +2 -2
- package/node_modules/@slack/web-api/node_modules/@types/node/perf_hooks.d.ts +2 -1
- package/node_modules/@slack/web-api/node_modules/@types/node/process.d.ts +42 -43
- package/node_modules/@slack/web-api/node_modules/@types/node/quic.d.ts +1049 -84
- package/node_modules/@slack/web-api/node_modules/@types/node/sqlite.d.ts +14 -1
- package/node_modules/@slack/web-api/node_modules/@types/node/stream/iter.d.ts +3 -2
- package/node_modules/@slack/web-api/node_modules/@types/node/test.d.ts +61 -0
- package/node_modules/@slack/web-api/node_modules/@types/node/v8.d.ts +20 -23
- package/node_modules/typebox/build/format/date.d.mts +1 -1
- package/node_modules/typebox/build/format/date.mjs +1 -1
- package/node_modules/typebox/build/format/date_time.d.mts +2 -2
- package/node_modules/typebox/build/format/date_time.mjs +3 -3
- package/node_modules/typebox/build/format/email.d.mts +1 -1
- package/node_modules/typebox/build/format/email.mjs +2 -2
- package/node_modules/typebox/build/format/hostname.mjs +2 -10
- package/node_modules/typebox/build/format/idn_email.d.mts +1 -1
- package/node_modules/typebox/build/format/idn_email.mjs +3 -3
- package/node_modules/typebox/build/format/idn_hostname.d.mts +1 -0
- package/node_modules/typebox/build/format/idn_hostname.mjs +3 -11
- package/node_modules/typebox/build/format/idna/format/bidi.d.mts +3 -0
- package/node_modules/typebox/build/format/idna/format/bidi.mjs +98 -0
- package/node_modules/typebox/build/format/idna/format/puny.d.mts +3 -0
- package/node_modules/typebox/build/format/idna/format/puny.mjs +144 -0
- package/node_modules/typebox/build/format/idna/hostname.d.mts +1 -0
- package/node_modules/typebox/build/format/idna/hostname.mjs +16 -0
- package/node_modules/typebox/build/format/idna/idn-hostname.d.mts +1 -0
- package/node_modules/typebox/build/format/idna/idn-hostname.mjs +23 -0
- package/node_modules/typebox/build/format/idna/index.d.mts +2 -0
- package/node_modules/typebox/build/format/idna/index.mjs +2 -0
- package/node_modules/typebox/build/format/idna/label/ascii.d.mts +1 -0
- package/node_modules/typebox/build/format/idna/label/ascii.mjs +9 -0
- package/node_modules/typebox/build/format/idna/label/puny.d.mts +1 -0
- package/node_modules/typebox/build/format/idna/label/puny.mjs +28 -0
- package/node_modules/typebox/build/format/idna/label/unicode.d.mts +1 -0
- package/node_modules/typebox/build/format/idna/label/unicode.mjs +106 -0
- package/node_modules/typebox/build/format/idna/pattern/pattern.d.mts +30 -0
- package/node_modules/typebox/build/format/idna/pattern/pattern.mjs +70 -0
- package/node_modules/typebox/build/format/ipv4.d.mts +0 -1
- package/node_modules/typebox/build/format/ipv4.mjs +2 -32
- package/node_modules/typebox/build/format/ipv6.mjs +2 -61
- package/node_modules/typebox/build/format/iri.d.mts +2 -2
- package/node_modules/typebox/build/format/iri.mjs +26 -8
- package/node_modules/typebox/build/format/iri_reference.d.mts +2 -2
- package/node_modules/typebox/build/format/iri_reference.mjs +9 -55
- package/node_modules/typebox/build/format/regex.d.mts +1 -2
- package/node_modules/typebox/build/format/regex.mjs +2 -6
- package/node_modules/typebox/build/format/time.d.mts +2 -2
- package/node_modules/typebox/build/format/time.mjs +19 -14
- package/node_modules/typebox/build/format/uri.d.mts +1 -1
- package/node_modules/typebox/build/format/uri.mjs +3 -130
- package/node_modules/typebox/build/format/uri_reference.d.mts +1 -1
- package/node_modules/typebox/build/format/uri_reference.mjs +2 -3
- package/node_modules/typebox/build/format/uri_template.d.mts +2 -3
- package/node_modules/typebox/build/format/uri_template.mjs +4 -5
- package/node_modules/typebox/build/format/url.d.mts +3 -3
- package/node_modules/typebox/build/format/url.mjs +4 -5
- package/node_modules/typebox/build/guard/emit.d.mts +3 -1
- package/node_modules/typebox/build/guard/emit.mjs +12 -5
- package/node_modules/typebox/build/guard/guard.d.mts +8 -2
- package/node_modules/typebox/build/guard/guard.mjs +25 -4
- package/node_modules/typebox/build/guard/string.d.mts +2 -2
- package/node_modules/typebox/build/guard/string.mjs +7 -7
- package/node_modules/typebox/build/schema/engine/_context.mjs +3 -3
- package/node_modules/typebox/build/schema/engine/_functions.mjs +1 -2
- package/node_modules/typebox/build/schema/engine/_regexp.d.mts +2 -0
- package/node_modules/typebox/build/schema/engine/_regexp.mjs +4 -0
- package/node_modules/typebox/build/schema/engine/_stack.mjs +12 -13
- package/node_modules/typebox/build/schema/engine/additionalItems.mjs +17 -7
- package/node_modules/typebox/build/schema/engine/additionalProperties.mjs +4 -3
- package/node_modules/typebox/build/schema/engine/contains.mjs +18 -6
- package/node_modules/typebox/build/schema/engine/enum.mjs +1 -1
- package/node_modules/typebox/build/schema/engine/items.mjs +26 -6
- package/node_modules/typebox/build/schema/engine/maxContains.mjs +3 -3
- package/node_modules/typebox/build/schema/engine/minContains.mjs +14 -4
- package/node_modules/typebox/build/schema/engine/not.mjs +4 -2
- package/node_modules/typebox/build/schema/engine/oneOf.mjs +7 -6
- package/node_modules/typebox/build/schema/engine/pattern.mjs +3 -2
- package/node_modules/typebox/build/schema/engine/patternProperties.mjs +4 -3
- package/node_modules/typebox/build/schema/engine/ref.mjs +1 -7
- package/node_modules/typebox/build/schema/engine/schema.mjs +13 -4
- package/node_modules/typebox/build/schema/engine/type.mjs +1 -1
- package/node_modules/typebox/build/schema/resolve/resolve.d.mts +4 -1
- package/node_modules/typebox/build/schema/resolve/resolve.mjs +202 -1
- package/node_modules/typebox/build/schema/static/propertyNames.d.mts +5 -0
- package/node_modules/typebox/build/schema/static/propertyNames.mjs +3 -0
- package/node_modules/typebox/build/schema/static/schema.d.mts +3 -0
- package/node_modules/typebox/build/schema/types/index.d.mts +0 -2
- package/node_modules/typebox/build/schema/types/index.mjs +0 -2
- package/node_modules/typebox/build/system/memory/clone.mjs +14 -11
- package/node_modules/typebox/build/system/memory/discard.mjs +6 -5
- package/node_modules/typebox/build/system/settings/settings.d.mts +9 -0
- package/node_modules/typebox/build/system/settings/settings.mjs +2 -0
- package/node_modules/typebox/build/type/engine/call/distribute_arguments.d.mts +6 -1
- package/node_modules/typebox/build/type/engine/call/distribute_arguments.mjs +16 -3
- package/node_modules/typebox/build/type/engine/call/instantiate.mjs +34 -4
- package/node_modules/typebox/build/type/engine/evaluate/broaden.d.mts +5 -5
- package/node_modules/typebox/build/type/engine/evaluate/broaden.mjs +20 -26
- package/node_modules/typebox/build/type/engine/evaluate/compare.d.mts +6 -10
- package/node_modules/typebox/build/type/engine/evaluate/compare.mjs +9 -13
- package/node_modules/typebox/build/type/engine/evaluate/composite.d.mts +7 -4
- package/node_modules/typebox/build/type/engine/evaluate/composite.mjs +12 -19
- package/node_modules/typebox/build/type/engine/evaluate/distribute.d.mts +4 -20
- package/node_modules/typebox/build/type/engine/evaluate/distribute.mjs +8 -20
- package/node_modules/typebox/build/type/engine/evaluate/evaluate.d.mts +4 -4
- package/node_modules/typebox/build/type/engine/evaluate/evaluate.mjs +11 -8
- package/node_modules/typebox/build/type/engine/evaluate/flatten.d.mts +1 -1
- package/node_modules/typebox/build/type/engine/evaluate/flatten.mjs +3 -4
- package/node_modules/typebox/build/type/engine/evaluate/narrow.d.mts +17 -2
- package/node_modules/typebox/build/type/engine/evaluate/narrow.mjs +26 -6
- package/node_modules/typebox/build/type/engine/exclude/operation.mjs +3 -4
- package/node_modules/typebox/build/type/engine/extract/operation.d.mts +1 -1
- package/node_modules/typebox/build/type/engine/extract/operation.mjs +3 -4
- package/node_modules/typebox/build/type/engine/priority/priority.d.mts +2 -2
- package/node_modules/typebox/build/type/engine/priority/priority.mjs +3 -4
- package/node_modules/typebox/build/type/script/mapping.d.mts +32 -29
- package/node_modules/typebox/build/type/script/mapping.mjs +18 -25
- package/node_modules/typebox/build/type/script/parser.d.mts +19 -25
- package/node_modules/typebox/build/type/script/parser.mjs +27 -23
- package/node_modules/typebox/build/value/errors/errors.d.mts +2 -2
- package/node_modules/typebox/build/value/errors/errors.mjs +1 -1
- package/node_modules/typebox/package.json +27 -27
- package/node_modules/typebox/readme.md +79 -82
- package/node_modules/ws/lib/permessage-deflate.js +3 -1
- package/node_modules/ws/package.json +1 -1
- package/openclaw.plugin.json +14 -6
- package/package.json +9 -7
- package/dist/account-configured-BwfXBo_F.js +0 -14
- package/dist/account-inspect-YJvFBbCR.js +0 -89
- package/dist/action-runtime.runtime-JtoOK9l5.js +0 -2
- package/dist/actions.runtime-CYLsYRai.js +0 -2
- package/dist/runtime-api-DBi7xc_g.js +0 -10
- package/dist/slack-client-kind-BXyOOICI.js +0 -94
- package/node_modules/typebox/build/format/_idna.d.mts +0 -2
- package/node_modules/typebox/build/format/_idna.mjs +0 -246
- package/node_modules/typebox/build/format/_puny.d.mts +0 -1
- package/node_modules/typebox/build/format/_puny.mjs +0 -77
- package/node_modules/typebox/build/schema/resolve/ref.d.mts +0 -3
- package/node_modules/typebox/build/schema/resolve/ref.mjs +0 -146
- package/node_modules/typebox/build/schema/types/contentEncoding.d.mts +0 -9
- package/node_modules/typebox/build/schema/types/contentEncoding.mjs +0 -13
- package/node_modules/typebox/build/schema/types/contentMediaType.d.mts +0 -9
- package/node_modules/typebox/build/schema/types/contentMediaType.mjs +0 -13
|
@@ -1,12 +1,14 @@
|
|
|
1
1
|
import { t as __exportAll } from "./rolldown-runtime-8H4AJuhK.js";
|
|
2
|
-
import { a as resolveSlackAccount, f as resolveSlackBotToken } from "./accounts-
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import { m as buildSlackNativeDataDeliveryPlan, r as sendMessageSlack } from "./send-
|
|
2
|
+
import { a as resolveSlackAccount, f as resolveSlackBotToken, i as resolveDefaultSlackAccountId } from "./accounts-Dm_H77gH.js";
|
|
3
|
+
import { n as formatSlackTarget } from "./target-parsing-BnMD2ZqZ.js";
|
|
4
|
+
import { At as SLACK_PRIVATE_ACTION_DELIVERY_RESULT, D as renderSlackBlockFallbackText, E as buildSlackCompleteBlocksFallbackText, I as countSlackTextUtf8Bytes, Q as normalizeSlackOutboundText, R as truncateSlackTextByUtf8Bytes, T as buildSlackBlocksFallbackText, _ as appendSlackNativeDataPlainTextFallback, b as hasSlackNativeDataBlock, c as assertSlackDetachedTargetAllowed, et as escapeSlackMrkdwn, g as appendSlackNativeDataFallbackText, k as SLACK_EDIT_TEXT_MAX_BYTES, st as validateSlackBlocksArray, w as stripSlackNativeDataBlocks, x as isSlackInvalidBlocksError } from "./group-policy-BdwszjYn.js";
|
|
5
|
+
import { S as getSlackWriteClient, h as createSlackLookupClient } from "./probe-0usmAb0i.js";
|
|
6
|
+
import { m as buildSlackNativeDataDeliveryPlan, r as sendMessageSlack } from "./send-DS9ICrBI.js";
|
|
7
7
|
import { normalizeAccountId } from "openclaw/plugin-sdk/account-resolution";
|
|
8
8
|
import { normalizeLowercaseStringOrEmpty, normalizeOptionalLowercaseString, normalizeOptionalString } from "openclaw/plugin-sdk/string-coerce-runtime";
|
|
9
|
-
import { logVerbose, logVerbose as logVerbose$1 } from "openclaw/plugin-sdk/runtime-env";
|
|
9
|
+
import { createSubsystemLogger, logVerbose, logVerbose as logVerbose$1 } from "openclaw/plugin-sdk/runtime-env";
|
|
10
|
+
import { resolveMarkdownTableMode } from "openclaw/plugin-sdk/markdown-table-runtime";
|
|
11
|
+
import { redactToolPayloadText } from "openclaw/plugin-sdk/logging-core";
|
|
10
12
|
import { z } from "zod";
|
|
11
13
|
import { requireRuntimeConfig } from "openclaw/plugin-sdk/plugin-config-runtime";
|
|
12
14
|
import fs from "node:fs/promises";
|
|
@@ -14,6 +16,31 @@ import { runTasksWithConcurrency } from "openclaw/plugin-sdk/concurrency-runtime
|
|
|
14
16
|
import { formatErrorMessage } from "openclaw/plugin-sdk/error-runtime";
|
|
15
17
|
import { normalizeHostname } from "openclaw/plugin-sdk/host-runtime";
|
|
16
18
|
import { resolveRequestUrl } from "openclaw/plugin-sdk/request-url";
|
|
19
|
+
import { fetchWithRuntimeDispatcher } from "openclaw/plugin-sdk/runtime-fetch";
|
|
20
|
+
import { saveRemoteMedia } from "openclaw/plugin-sdk/media-runtime";
|
|
21
|
+
//#region extensions/slack/src/conversation-open.ts
|
|
22
|
+
function parseSlackConversationOpenInput(userIds, teamId) {
|
|
23
|
+
const users = z.array(z.string().trim().regex(/^[UW][A-Z0-9]+$/)).min(1).max(8).parse(userIds);
|
|
24
|
+
if (new Set(users).size !== users.length) throw new Error("Slack conversation-open requires distinct userIds.");
|
|
25
|
+
return {
|
|
26
|
+
users,
|
|
27
|
+
teamId: teamId === void 0 ? void 0 : z.string().trim().regex(/^T[A-Z0-9]+$/i).parse(teamId)
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
async function openSlackConversationWithClient(client, input) {
|
|
31
|
+
const channelId = (await client.conversations.open({ users: input.users.join(",") })).channel?.id?.trim();
|
|
32
|
+
if (!channelId || !/^[CDG][A-Z0-9]+$/i.test(channelId)) throw new Error("Slack conversations.open did not return a valid conversation ID.");
|
|
33
|
+
return {
|
|
34
|
+
channelId,
|
|
35
|
+
target: formatSlackTarget({
|
|
36
|
+
teamId: input.teamId,
|
|
37
|
+
kind: "channel",
|
|
38
|
+
id: channelId,
|
|
39
|
+
explicitKind: true
|
|
40
|
+
})
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
//#endregion
|
|
17
44
|
//#region extensions/slack/src/edit-text.ts
|
|
18
45
|
function buildSlackEditTextPayload(content, blocks) {
|
|
19
46
|
const trimmedContent = content.trim();
|
|
@@ -27,6 +54,85 @@ function buildSlackEditTextPayload(content, blocks) {
|
|
|
27
54
|
return " ";
|
|
28
55
|
}
|
|
29
56
|
//#endregion
|
|
57
|
+
//#region extensions/slack/src/monitor/block-text.ts
|
|
58
|
+
function readSlackBlockType(block) {
|
|
59
|
+
return block && typeof block === "object" && !Array.isArray(block) ? block.type : void 0;
|
|
60
|
+
}
|
|
61
|
+
function hasSlackTableBlock(blocks) {
|
|
62
|
+
return blocks?.some((block) => readSlackBlockType(block) === "table") ?? false;
|
|
63
|
+
}
|
|
64
|
+
function hasSlackMessageTableBlock(message) {
|
|
65
|
+
return hasSlackTableBlock(message.blocks) || message.attachments?.some((attachment) => !isSlackUnfurlAttachment(attachment) && hasSlackTableBlock(attachment.blocks)) === true;
|
|
66
|
+
}
|
|
67
|
+
function isSlackUnfurlAttachment(attachment) {
|
|
68
|
+
return attachment.is_msg_unfurl === true || attachment.is_app_unfurl === true || typeof attachment.app_unfurl_url === "string" && attachment.app_unfurl_url.trim().length > 0;
|
|
69
|
+
}
|
|
70
|
+
function resolveSlackBlocksText(blocks) {
|
|
71
|
+
if (!blocks?.length) return;
|
|
72
|
+
const parts = [];
|
|
73
|
+
let hasRichText = false;
|
|
74
|
+
let hasNativeData = false;
|
|
75
|
+
for (const block of blocks) {
|
|
76
|
+
const blockType = readSlackBlockType(block);
|
|
77
|
+
hasRichText ||= blockType === "rich_text";
|
|
78
|
+
hasNativeData ||= blockType === "data_visualization" || blockType === "data_table" || blockType === "table";
|
|
79
|
+
const text = renderSlackBlockFallbackText(block, {
|
|
80
|
+
nativeDataFormat: "plain",
|
|
81
|
+
nativeReferenceFormat: "plain"
|
|
82
|
+
});
|
|
83
|
+
if (text) parts.push(text);
|
|
84
|
+
}
|
|
85
|
+
return parts.length > 0 ? {
|
|
86
|
+
text: parts.join("\n"),
|
|
87
|
+
hasRichText,
|
|
88
|
+
hasNativeData
|
|
89
|
+
} : void 0;
|
|
90
|
+
}
|
|
91
|
+
function appendDistinctSlackText(base, addition) {
|
|
92
|
+
if (!base) return addition;
|
|
93
|
+
const comparableBase = `\n${base.replace(/\r\n?/g, "\n")}\n`;
|
|
94
|
+
const comparableAddition = `\n${addition.replace(/\r\n?/g, "\n")}\n`;
|
|
95
|
+
if (comparableBase.includes(comparableAddition)) return base;
|
|
96
|
+
return `${base}\n${addition}`;
|
|
97
|
+
}
|
|
98
|
+
function resolveSlackAttachmentTableTexts(attachments) {
|
|
99
|
+
const seen = /* @__PURE__ */ new Set();
|
|
100
|
+
const texts = [];
|
|
101
|
+
for (const attachment of attachments ?? []) {
|
|
102
|
+
if (isSlackUnfurlAttachment(attachment)) continue;
|
|
103
|
+
for (const block of attachment.blocks ?? []) {
|
|
104
|
+
if (readSlackBlockType(block) !== "table") continue;
|
|
105
|
+
const text = renderSlackBlockFallbackText(block, { nativeDataFormat: "plain" });
|
|
106
|
+
if (!text || seen.has(text)) continue;
|
|
107
|
+
seen.add(text);
|
|
108
|
+
texts.push(text);
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
return texts;
|
|
112
|
+
}
|
|
113
|
+
/** Resolve agent-visible Slack text while admitting only native tables from attachments. */
|
|
114
|
+
function resolveSlackMessageText(message, options = {}) {
|
|
115
|
+
let resolved = chooseSlackPrimaryText({
|
|
116
|
+
messageText: options.preserveMessageTextWhitespace ? typeof message.text === "string" && message.text.trim().length > 0 ? message.text : void 0 : normalizeOptionalString(message.text),
|
|
117
|
+
blocksText: resolveSlackBlocksText(message.blocks)
|
|
118
|
+
});
|
|
119
|
+
for (const tableText of resolveSlackAttachmentTableTexts(message.attachments)) resolved = appendDistinctSlackText(resolved, tableText);
|
|
120
|
+
return resolved;
|
|
121
|
+
}
|
|
122
|
+
function chooseSlackPrimaryText(params) {
|
|
123
|
+
const { messageText, blocksText } = params;
|
|
124
|
+
if (!blocksText) return messageText;
|
|
125
|
+
if (!messageText) return blocksText.text;
|
|
126
|
+
if (blocksText.hasNativeData) {
|
|
127
|
+
const comparableMessageText = messageText.replace(/\s+/g, " ").trim();
|
|
128
|
+
const comparableBlocksText = blocksText.text.replace(/\s+/g, " ").trim();
|
|
129
|
+
if (comparableMessageText.includes(comparableBlocksText)) return messageText;
|
|
130
|
+
return comparableBlocksText.startsWith(comparableMessageText) ? blocksText.text : `${messageText}\n${blocksText.text}`;
|
|
131
|
+
}
|
|
132
|
+
if (blocksText.hasRichText && blocksText.text.length > messageText.length) return blocksText.text;
|
|
133
|
+
return blocksText.text.length > messageText.length && blocksText.text.startsWith(messageText) ? blocksText.text : messageText;
|
|
134
|
+
}
|
|
135
|
+
//#endregion
|
|
30
136
|
//#region extensions/slack/src/file-reference.ts
|
|
31
137
|
function formatSlackFileReference(file) {
|
|
32
138
|
const name = normalizeOptionalString(file?.name) ?? "file";
|
|
@@ -45,6 +151,21 @@ function formatSlackFileReferenceList(files) {
|
|
|
45
151
|
return files.map((file) => formatSlackFileReference(file)).join(", ");
|
|
46
152
|
}
|
|
47
153
|
//#endregion
|
|
154
|
+
//#region extensions/slack/src/monitor/media.runtime.ts
|
|
155
|
+
const slackMediaLog = createSubsystemLogger("gateway/channels/slack").child("media");
|
|
156
|
+
//#endregion
|
|
157
|
+
//#region extensions/slack/src/monitor/slack-client-kind.ts
|
|
158
|
+
/** Detects the isolated GovSlack API plane without consulting mutable config. */
|
|
159
|
+
function isGovSlackClient(client) {
|
|
160
|
+
if (!client?.slackApiUrl) return false;
|
|
161
|
+
try {
|
|
162
|
+
const apiUrl = new URL(client.slackApiUrl);
|
|
163
|
+
return apiUrl.protocol === "https:" && !apiUrl.port && normalizeHostname(apiUrl.hostname) === "slack-gov.com";
|
|
164
|
+
} catch {
|
|
165
|
+
return false;
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
//#endregion
|
|
48
169
|
//#region extensions/slack/src/monitor/media.ts
|
|
49
170
|
var media_exports = /* @__PURE__ */ __exportAll({
|
|
50
171
|
SLACK_MEDIA_READ_IDLE_TIMEOUT_MS: () => SLACK_MEDIA_READ_IDLE_TIMEOUT_MS,
|
|
@@ -180,10 +301,18 @@ async function looksLikeHtmlFile(filePath) {
|
|
|
180
301
|
}
|
|
181
302
|
const MAX_SLACK_MEDIA_CONCURRENCY = 3;
|
|
182
303
|
const MAX_SLACK_FORWARDED_ATTACHMENTS = 8;
|
|
304
|
+
const SLACK_MEDIA_LIMIT_REASON = `omitted: 8-file limit`;
|
|
305
|
+
function formatSlackMediaFailure(error) {
|
|
306
|
+
return redactToolPayloadText(formatErrorMessage(error)).replace(/\s+/g, " ").slice(0, 200);
|
|
307
|
+
}
|
|
183
308
|
async function fetchFreshSlackFileUrl(params) {
|
|
184
309
|
if (!params.file.id || !params.client) return null;
|
|
185
310
|
try {
|
|
186
311
|
const freshFile = (await params.client.files.info({ file: params.file.id })).file;
|
|
312
|
+
if (freshFile && params.isRefreshedFileAllowed?.(freshFile) === false) {
|
|
313
|
+
logVerbose$1(`slack: refreshed file metadata rejected for file id=${params.file.id}`);
|
|
314
|
+
return null;
|
|
315
|
+
}
|
|
187
316
|
const freshUrl = freshFile?.url_private_download ?? freshFile?.url_private;
|
|
188
317
|
if (freshUrl) {
|
|
189
318
|
logVerbose$1(`slack: refreshed file URL via files.info for file id=${params.file.id}`);
|
|
@@ -217,7 +346,7 @@ async function downloadSlackMediaFile(params) {
|
|
|
217
346
|
if (!(fileMime === "text/html" || fileName.endsWith(".html") || fileName.endsWith(".htm"))) {
|
|
218
347
|
if (normalizeOptionalLowercaseString(saved.contentType?.split(";")[0]) === "text/html" || await looksLikeHtmlFile(saved.path)) {
|
|
219
348
|
await fs.rm(saved.path, { force: true }).catch(() => void 0);
|
|
220
|
-
|
|
349
|
+
throw new Error("blocked: unexpected HTML content");
|
|
221
350
|
}
|
|
222
351
|
}
|
|
223
352
|
const effectiveMime = resolveSlackMediaMimetype(params.file, saved.contentType);
|
|
@@ -226,6 +355,7 @@ async function downloadSlackMediaFile(params) {
|
|
|
226
355
|
return {
|
|
227
356
|
path: saved.path,
|
|
228
357
|
...contentType ? { contentType } : {},
|
|
358
|
+
...label ? { fileName: label } : {},
|
|
229
359
|
placeholder: `[Slack file: ${formatSlackFileReference({
|
|
230
360
|
...params.file,
|
|
231
361
|
name: label
|
|
@@ -253,42 +383,36 @@ function resolveForwardedAttachmentImageUrl(attachment, govSlack) {
|
|
|
253
383
|
async function resolveSlackMedia(params) {
|
|
254
384
|
const govSlack = isGovSlackClient(params.client);
|
|
255
385
|
const files = params.files ?? [];
|
|
386
|
+
const limitedFiles = files.length > 8 ? files.slice(0, 8) : files;
|
|
387
|
+
for (const file of files.slice(8)) params.unavailableFiles?.set(file, SLACK_MEDIA_LIMIT_REASON);
|
|
388
|
+
const refreshFileUrl = (file) => fetchFreshSlackFileUrl({
|
|
389
|
+
file,
|
|
390
|
+
client: params.client,
|
|
391
|
+
isRefreshedFileAllowed: params.isRefreshedFileAllowed
|
|
392
|
+
});
|
|
256
393
|
const { results } = await runTasksWithConcurrency({
|
|
257
|
-
tasks:
|
|
394
|
+
tasks: limitedFiles.map((file) => async () => {
|
|
258
395
|
const preloaded = params.preloadedMedia?.get(file);
|
|
259
396
|
if (preloaded) return preloaded;
|
|
260
397
|
const eventUrl = file.url_private_download ?? file.url_private;
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
}
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
client: params.client
|
|
280
|
-
});
|
|
281
|
-
if (!freshUrl) return null;
|
|
282
|
-
return await downloadSlackMediaFile({
|
|
283
|
-
file,
|
|
284
|
-
url: freshUrl,
|
|
285
|
-
token: params.token,
|
|
286
|
-
maxBytes: params.maxBytes,
|
|
287
|
-
readIdleTimeoutMs: params.readIdleTimeoutMs,
|
|
288
|
-
totalTimeoutMs: params.totalTimeoutMs,
|
|
289
|
-
abortSignal: params.abortSignal,
|
|
290
|
-
govSlack
|
|
291
|
-
}).catch(() => null);
|
|
398
|
+
let url = eventUrl ?? await refreshFileUrl(file);
|
|
399
|
+
let reason = "no private download URL";
|
|
400
|
+
for (let attempt = 0; url && attempt < 2; attempt += 1) {
|
|
401
|
+
try {
|
|
402
|
+
return await downloadSlackMediaFile({
|
|
403
|
+
...params,
|
|
404
|
+
file,
|
|
405
|
+
url,
|
|
406
|
+
govSlack
|
|
407
|
+
});
|
|
408
|
+
} catch (error) {
|
|
409
|
+
reason = formatSlackMediaFailure(error);
|
|
410
|
+
}
|
|
411
|
+
url = attempt === 0 && eventUrl ? await refreshFileUrl(file) : null;
|
|
412
|
+
}
|
|
413
|
+
params.unavailableFiles?.set(file, reason);
|
|
414
|
+
slackMediaLog.warn(`slack: file ${formatSlackFileReference(file)} unavailable (${reason})`);
|
|
415
|
+
return null;
|
|
292
416
|
}),
|
|
293
417
|
limit: MAX_SLACK_MEDIA_CONCURRENCY,
|
|
294
418
|
errorMode: "stop",
|
|
@@ -299,14 +423,41 @@ async function resolveSlackMedia(params) {
|
|
|
299
423
|
}
|
|
300
424
|
/** Extracts text and media from forwarded-message attachments. Returns null when empty. */
|
|
301
425
|
async function resolveSlackAttachmentContent(params) {
|
|
302
|
-
const
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
426
|
+
const forwardedAttachments = (params.attachments ?? []).filter((attachment) => isForwardedSlackAttachment(attachment)).slice(0, MAX_SLACK_FORWARDED_ATTACHMENTS);
|
|
427
|
+
const candidates = [...params.files ?? [], ...forwardedAttachments.flatMap((attachment) => attachment.files ?? [])];
|
|
428
|
+
if (forwardedAttachments.length === 0 && candidates.length === 0) return null;
|
|
429
|
+
const fileIds = /* @__PURE__ */ new Set();
|
|
430
|
+
const allFiles = candidates.filter((file) => {
|
|
431
|
+
const fileId = normalizeOptionalString(file.id);
|
|
432
|
+
if (!fileId) return true;
|
|
433
|
+
if (fileIds.has(fileId)) return false;
|
|
434
|
+
fileIds.add(fileId);
|
|
435
|
+
return true;
|
|
436
|
+
}).map((file, index) => {
|
|
437
|
+
if (index >= 8) return file;
|
|
438
|
+
const fileId = normalizeOptionalString(file.id);
|
|
439
|
+
const preloaded = fileId && candidates.find((candidate) => normalizeOptionalString(candidate.id) === fileId && params.preloadedMedia?.has(candidate));
|
|
440
|
+
if (preloaded) return preloaded;
|
|
441
|
+
if (!fileId || file.url_private_download || file.url_private) return file;
|
|
442
|
+
const downloadable = candidates.find((candidate) => normalizeOptionalString(candidate.id) === fileId && (candidate.url_private_download || candidate.url_private));
|
|
443
|
+
return downloadable ? Object.assign({}, file, downloadable) : file;
|
|
444
|
+
});
|
|
445
|
+
const pendingFiles = new Map(allFiles.slice(0, 8).map((file) => [normalizeOptionalString(file.id) ?? file, file]));
|
|
446
|
+
const unavailableFileReasons = /* @__PURE__ */ new Map();
|
|
447
|
+
const resolveFiles = (files) => resolveSlackMedia({
|
|
448
|
+
...params,
|
|
449
|
+
unavailableFiles: unavailableFileReasons,
|
|
450
|
+
files: files?.flatMap((file) => {
|
|
451
|
+
const key = normalizeOptionalString(file.id) ?? file;
|
|
452
|
+
const selected = pendingFiles.get(key);
|
|
453
|
+
pendingFiles.delete(key);
|
|
454
|
+
return selected ? [selected] : [];
|
|
455
|
+
})
|
|
456
|
+
});
|
|
457
|
+
const directMediaPromise = resolveFiles(params.files);
|
|
306
458
|
const textBlocks = [];
|
|
307
|
-
const
|
|
308
|
-
|
|
309
|
-
let unavailableImageCount = 0;
|
|
459
|
+
const attachmentMedia = [];
|
|
460
|
+
let unavailableMediaCount = 0;
|
|
310
461
|
const govSlack = isGovSlackClient(params.client);
|
|
311
462
|
for (const att of forwardedAttachments) {
|
|
312
463
|
const text = att.text?.trim() || att.fallback?.trim();
|
|
@@ -331,38 +482,57 @@ async function resolveSlackAttachmentContent(params) {
|
|
|
331
482
|
abortSignal: params.abortSignal
|
|
332
483
|
});
|
|
333
484
|
const label = saved.fileName ?? "forwarded image";
|
|
334
|
-
|
|
485
|
+
attachmentMedia.push({
|
|
335
486
|
path: saved.path,
|
|
336
487
|
contentType: saved.contentType,
|
|
488
|
+
...saved.fileName ? { fileName: saved.fileName } : {},
|
|
337
489
|
placeholder: `[Forwarded image: ${label}]`
|
|
338
490
|
});
|
|
339
|
-
} catch {
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
if (att.files && att.files.length > 0) {
|
|
343
|
-
const fileMedia = await resolveSlackMedia({
|
|
344
|
-
files: att.files,
|
|
345
|
-
client: params.client,
|
|
346
|
-
token: params.token,
|
|
347
|
-
maxBytes: params.maxBytes,
|
|
348
|
-
readIdleTimeoutMs: params.readIdleTimeoutMs,
|
|
349
|
-
totalTimeoutMs: params.totalTimeoutMs,
|
|
350
|
-
abortSignal: params.abortSignal
|
|
351
|
-
});
|
|
352
|
-
if (fileMedia) allMedia.push(...fileMedia);
|
|
491
|
+
} catch (error) {
|
|
492
|
+
unavailableMediaCount += 1;
|
|
493
|
+
slackMediaLog.warn(`slack: forwarded image unavailable (${formatSlackMediaFailure(error)})`);
|
|
353
494
|
}
|
|
495
|
+
attachmentMedia.push(...await resolveFiles(att.files) ?? []);
|
|
354
496
|
}
|
|
497
|
+
const allMedia = [...await directMediaPromise ?? [], ...attachmentMedia];
|
|
498
|
+
const unavailableFiles = allFiles.flatMap((file, index) => {
|
|
499
|
+
const reason = index >= 8 ? SLACK_MEDIA_LIMIT_REASON : unavailableFileReasons.get(file);
|
|
500
|
+
return reason ? [{
|
|
501
|
+
...file,
|
|
502
|
+
reason
|
|
503
|
+
}] : [];
|
|
504
|
+
});
|
|
505
|
+
unavailableMediaCount += unavailableFiles.length;
|
|
355
506
|
const combinedText = textBlocks.join("\n\n");
|
|
356
|
-
if (!combinedText && allMedia.length === 0 && allFiles.length === 0 &&
|
|
507
|
+
if (!combinedText && allMedia.length === 0 && allFiles.length === 0 && unavailableMediaCount === 0) return null;
|
|
357
508
|
return {
|
|
358
509
|
text: combinedText,
|
|
359
510
|
media: allMedia,
|
|
360
|
-
|
|
361
|
-
...
|
|
511
|
+
unavailableMediaCount,
|
|
512
|
+
...unavailableFiles.length > 0 ? { files: unavailableFiles } : {}
|
|
362
513
|
};
|
|
363
514
|
}
|
|
364
515
|
//#endregion
|
|
365
516
|
//#region extensions/slack/src/actions.ts
|
|
517
|
+
var actions_exports = /* @__PURE__ */ __exportAll({
|
|
518
|
+
deleteSlackMessage: () => deleteSlackMessage,
|
|
519
|
+
downloadSlackFile: () => downloadSlackFile,
|
|
520
|
+
editSlackMessage: () => editSlackMessage,
|
|
521
|
+
editSlackRenderedMessage: () => editSlackRenderedMessage,
|
|
522
|
+
getSlackMemberInfo: () => getSlackMemberInfo,
|
|
523
|
+
listSlackEmojis: () => listSlackEmojis,
|
|
524
|
+
listSlackPins: () => listSlackPins,
|
|
525
|
+
listSlackReactions: () => listSlackReactions,
|
|
526
|
+
openSlackConversation: () => openSlackConversation,
|
|
527
|
+
pinSlackMessage: () => pinSlackMessage,
|
|
528
|
+
reactSlackMessage: () => reactSlackMessage,
|
|
529
|
+
readSlackMessages: () => readSlackMessages,
|
|
530
|
+
removeOwnSlackReactions: () => removeOwnSlackReactions,
|
|
531
|
+
removeSlackReaction: () => removeSlackReaction,
|
|
532
|
+
resolveSlackConversationName: () => resolveSlackConversationName,
|
|
533
|
+
sendSlackMessage: () => sendSlackMessage,
|
|
534
|
+
unpinSlackMessage: () => unpinSlackMessage
|
|
535
|
+
});
|
|
366
536
|
function renderSlackReadMessageText(message) {
|
|
367
537
|
if (!hasSlackMessageTableBlock(message)) return message;
|
|
368
538
|
const text = resolveSlackMessageText(message, { preserveMessageTextWhitespace: true });
|
|
@@ -553,7 +723,12 @@ async function sendSlackMessage(to, content, opts) {
|
|
|
553
723
|
});
|
|
554
724
|
}
|
|
555
725
|
async function editSlackMessage(channelId, messageId, content, opts = {}) {
|
|
556
|
-
|
|
726
|
+
const accountId = opts.accountId ?? (opts.cfg ? resolveDefaultSlackAccountId(opts.cfg) : void 0);
|
|
727
|
+
await editSlackRenderedMessage(channelId, messageId, normalizeSlackOutboundText(content, { tableMode: resolveMarkdownTableMode({
|
|
728
|
+
cfg: opts.cfg,
|
|
729
|
+
channel: "slack",
|
|
730
|
+
accountId
|
|
731
|
+
}) }), opts);
|
|
557
732
|
}
|
|
558
733
|
async function editSlackRenderedMessage(channelId, messageId, content, opts = {}) {
|
|
559
734
|
const client = await getClient(opts, "write");
|
|
@@ -598,6 +773,13 @@ async function deleteSlackMessage(channelId, messageId, opts = {}) {
|
|
|
598
773
|
ts: messageId
|
|
599
774
|
});
|
|
600
775
|
}
|
|
776
|
+
async function openSlackConversation(userIds, opts = {}) {
|
|
777
|
+
const input = parseSlackConversationOpenInput(userIds, opts.teamId);
|
|
778
|
+
return await openSlackConversationWithClient(await getClient({
|
|
779
|
+
...opts,
|
|
780
|
+
teamId: input.teamId
|
|
781
|
+
}, "write"), input);
|
|
782
|
+
}
|
|
601
783
|
async function resolveSlackConversationName(channelId, opts = {}) {
|
|
602
784
|
return (await (await getClient(opts, "read")).conversations.info({ channel: channelId })).channel?.name?.trim() || void 0;
|
|
603
785
|
}
|
|
@@ -682,48 +864,34 @@ function collectSlackShareMaps(file) {
|
|
|
682
864
|
const shares = file.shares;
|
|
683
865
|
return [shares.public, shares.private].filter((value) => Boolean(value) && typeof value === "object" && !Array.isArray(value));
|
|
684
866
|
}
|
|
685
|
-
function
|
|
686
|
-
const
|
|
687
|
-
for (const shareMap of collectSlackShareMaps(file)) for (const
|
|
688
|
-
const
|
|
689
|
-
if (
|
|
690
|
-
}
|
|
691
|
-
return ids;
|
|
692
|
-
}
|
|
693
|
-
function collectSlackThreadShares(file, channelId) {
|
|
694
|
-
const matches = [];
|
|
695
|
-
for (const shareMap of collectSlackShareMaps(file)) {
|
|
696
|
-
const rawEntries = shareMap[channelId];
|
|
697
|
-
if (!Array.isArray(rawEntries)) continue;
|
|
867
|
+
function collectSlackShares(file) {
|
|
868
|
+
const shares = [];
|
|
869
|
+
for (const shareMap of collectSlackShareMaps(file)) for (const [rawChannelId, rawEntries] of Object.entries(shareMap)) {
|
|
870
|
+
const channelId = normalizeOptionalString(rawChannelId);
|
|
871
|
+
if (!channelId || !Array.isArray(rawEntries)) continue;
|
|
698
872
|
for (const rawEntry of rawEntries) {
|
|
699
873
|
if (!rawEntry || typeof rawEntry !== "object" || Array.isArray(rawEntry)) continue;
|
|
700
874
|
const entry = rawEntry;
|
|
701
875
|
const ts = typeof entry.ts === "string" ? normalizeOptionalString(entry.ts) : void 0;
|
|
702
876
|
const threadTs = typeof entry.thread_ts === "string" ? normalizeOptionalString(entry.thread_ts) : void 0;
|
|
703
|
-
|
|
877
|
+
if (ts || threadTs) shares.push({
|
|
704
878
|
channelId,
|
|
705
879
|
ts,
|
|
706
880
|
threadTs
|
|
707
881
|
});
|
|
708
882
|
}
|
|
709
883
|
}
|
|
710
|
-
return
|
|
884
|
+
return shares;
|
|
711
885
|
}
|
|
712
|
-
function
|
|
886
|
+
function lacksSlackScopeProof(params) {
|
|
713
887
|
const channelId = normalizeOptionalString(params.channelId);
|
|
714
|
-
if (!channelId) return
|
|
888
|
+
if (!channelId) return true;
|
|
715
889
|
const threadId = normalizeOptionalString(params.threadId);
|
|
716
890
|
const directIds = collectSlackDirectShareChannelIds(params.file);
|
|
717
|
-
const
|
|
718
|
-
|
|
719
|
-
const inChannel = directIds.has(channelId) || sharedIds.has(channelId);
|
|
720
|
-
if (hasChannelEvidence && !inChannel) return true;
|
|
891
|
+
const shares = collectSlackShares(params.file);
|
|
892
|
+
if (!(directIds.has(channelId) || shares.some((entry) => entry.channelId === channelId))) return true;
|
|
721
893
|
if (!threadId) return false;
|
|
722
|
-
|
|
723
|
-
if (threadShares.length === 0) return false;
|
|
724
|
-
const threadEvidence = threadShares.filter((entry) => entry.threadTs || entry.ts);
|
|
725
|
-
if (threadEvidence.length === 0) return false;
|
|
726
|
-
return !threadEvidence.some((entry) => entry.threadTs === threadId || entry.ts === threadId);
|
|
894
|
+
return !shares.some((entry) => entry.channelId === channelId && (entry.threadTs === threadId || entry.ts === threadId));
|
|
727
895
|
}
|
|
728
896
|
/**
|
|
729
897
|
* Downloads a Slack file by ID and saves it to the local media store.
|
|
@@ -733,13 +901,14 @@ function hasSlackScopeMismatch(params) {
|
|
|
733
901
|
async function downloadSlackFile(fileId, opts) {
|
|
734
902
|
const token = resolveToken(opts.token, opts.accountId, opts.cfg);
|
|
735
903
|
const client = await getClient(opts);
|
|
736
|
-
const
|
|
737
|
-
if (!file?.url_private_download && !file?.url_private) return null;
|
|
738
|
-
if (hasSlackScopeMismatch({
|
|
904
|
+
const isFileAllowed = (file) => !lacksSlackScopeProof({
|
|
739
905
|
file,
|
|
740
906
|
channelId: opts.channelId,
|
|
741
907
|
threadId: opts.threadId
|
|
742
|
-
})
|
|
908
|
+
});
|
|
909
|
+
const file = (await client.files.info({ file: fileId })).file;
|
|
910
|
+
if (!file?.url_private_download && !file?.url_private) return null;
|
|
911
|
+
if (!isFileAllowed(file)) return null;
|
|
743
912
|
return (await resolveSlackMedia({
|
|
744
913
|
files: [{
|
|
745
914
|
id: file.id,
|
|
@@ -749,9 +918,10 @@ async function downloadSlackFile(fileId, opts) {
|
|
|
749
918
|
url_private_download: file.url_private_download
|
|
750
919
|
}],
|
|
751
920
|
client,
|
|
921
|
+
isRefreshedFileAllowed: isFileAllowed,
|
|
752
922
|
token,
|
|
753
923
|
maxBytes: opts.maxBytes
|
|
754
924
|
}))?.[0] ?? null;
|
|
755
925
|
}
|
|
756
926
|
//#endregion
|
|
757
|
-
export { media_exports as _,
|
|
927
|
+
export { hasSlackMessageTableBlock as C, resolveSlackMessageText as D, resolveSlackBlocksText as E, buildSlackEditTextPayload as O, formatSlackFileReferenceList as S, isSlackUnfurlAttachment as T, media_exports as _, editSlackRenderedMessage as a, saveRemoteMedia as b, listSlackPins as c, reactSlackMessage as d, readSlackMessages as f, unpinSlackMessage as g, sendSlackMessage as h, editSlackMessage as i, listSlackReactions as l, removeSlackReaction as m, deleteSlackMessage as n, getSlackMemberInfo as o, removeOwnSlackReactions as p, downloadSlackFile as r, listSlackEmojis as s, actions_exports as t, pinSlackMessage as u, logVerbose$1 as v, hasSlackTableBlock as w, formatSlackFileReference as x, isGovSlackClient as y };
|
package/dist/api.js
CHANGED
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
import { n as registerSlackHttpHandler, r as normalizeSlackWebhookPath, t as handleSlackHttpRequest } from "./registry-bbjH7IHX.js";
|
|
2
|
-
import { a as resolveSlackAccount, i as resolveDefaultSlackAccountId, n as listSlackAccountIds, r as mergeSlackAccountConfig, t as listEnabledSlackAccounts } from "./accounts-
|
|
2
|
+
import { a as resolveSlackAccount, i as resolveDefaultSlackAccountId, n as listSlackAccountIds, r as mergeSlackAccountConfig, t as listEnabledSlackAccounts } from "./accounts-Dm_H77gH.js";
|
|
3
3
|
import { r as resolveSlackReplyToMode } from "./conversation-binding-route-DFVLUdYF.js";
|
|
4
|
-
import { t as inspectSlackAccount } from "./account-inspect-
|
|
4
|
+
import { t as inspectSlackAccount } from "./account-inspect-CN2hBsim.js";
|
|
5
5
|
import { a as parseSlackTarget, i as normalizeSlackMessagingTarget, o as resolveSlackChannelId, r as looksLikeSlackTargetId } from "./target-parsing-BnMD2ZqZ.js";
|
|
6
6
|
import "./targets-Cx5W_n3W.js";
|
|
7
|
-
import {
|
|
8
|
-
import { n as buildSlackThreadingToolContext, t as slackPlugin } from "./channel-
|
|
9
|
-
import { n as extractSlackToolSend, r as listSlackMessageActions } from "./message-tool-api-
|
|
10
|
-
import {
|
|
11
|
-
import { n as resolveSlackChannelType } from "./channel-type-
|
|
12
|
-
import { t as slackSetupPlugin } from "./channel.setup-
|
|
13
|
-
import {
|
|
14
|
-
import { f as recordSlackThreadParticipation, l as hasSlackThreadParticipation, s as clearSlackThreadParticipationCache } from "./send-
|
|
15
|
-
import { n as listSlackDirectoryGroupsFromConfig, r as listSlackDirectoryPeersFromConfig } from "./directory-config-
|
|
7
|
+
import { N as buildSlackInteractiveBlocks, P as buildSlackPresentationBlocks, at as SLACK_MAX_BLOCKS, i as resolveSlackGroupToolPolicy, jt as resolveSlackAutoThreadId, ot as parseSlackBlocksInput, r as resolveSlackGroupRequireMention, st as validateSlackBlocksArray } from "./group-policy-BdwszjYn.js";
|
|
8
|
+
import { n as buildSlackThreadingToolContext, t as slackPlugin } from "./channel-1vIJOzPx.js";
|
|
9
|
+
import { n as extractSlackToolSend, r as listSlackMessageActions } from "./message-tool-api-CJ0kjcg5.js";
|
|
10
|
+
import { C as SLACK_DEFAULT_RETRY_OPTIONS, D as resolveSlackWebClientOptions, O as resolveSlackWriteClientOptions, S as getSlackWriteClient, b as createSlackWriteClient, c as normalizeAllowList, d as normalizeSlackSlug, f as resolveSlackAllowListMatch, l as normalizeAllowListLower, m as resolveSlackUserAllowed, s as allowListMatches, t as probeSlack, u as normalizeSlackAllowOwnerEntry, v as createSlackTokenCacheKey, w as SLACK_WRITE_RETRY_OPTIONS, y as createSlackWebClient } from "./probe-0usmAb0i.js";
|
|
11
|
+
import { n as resolveSlackChannelType } from "./channel-type-DlFSKeIZ.js";
|
|
12
|
+
import { t as slackSetupPlugin } from "./channel.setup-ofDi3_Pu.js";
|
|
13
|
+
import { c as listSlackPins, d as reactSlackMessage, f as readSlackMessages, g as unpinSlackMessage, h as sendSlackMessage, i as editSlackMessage, l as listSlackReactions, m as removeSlackReaction, n as deleteSlackMessage, o as getSlackMemberInfo, p as removeOwnSlackReactions, r as downloadSlackFile, s as listSlackEmojis, u as pinSlackMessage } from "./actions-BI7JkfVm.js";
|
|
14
|
+
import { f as recordSlackThreadParticipation, l as hasSlackThreadParticipation, s as clearSlackThreadParticipationCache } from "./send-DS9ICrBI.js";
|
|
15
|
+
import { n as listSlackDirectoryGroupsFromConfig, r as listSlackDirectoryPeersFromConfig } from "./directory-config-DqfQ42OV.js";
|
|
16
16
|
import { t as collectSlackSecurityAuditFindings } from "./security-audit-B_yKr7MW.js";
|
|
17
|
-
import { n as resolveSlackRuntimeGroupPolicy } from "./provider-
|
|
17
|
+
import { n as resolveSlackRuntimeGroupPolicy } from "./provider-CN_8hFv2.js";
|
|
18
18
|
export { SLACK_DEFAULT_RETRY_OPTIONS, SLACK_MAX_BLOCKS, SLACK_WRITE_RETRY_OPTIONS, allowListMatches, buildSlackInteractiveBlocks, buildSlackPresentationBlocks, buildSlackThreadingToolContext, clearSlackThreadParticipationCache, collectSlackSecurityAuditFindings, createSlackTokenCacheKey, createSlackWebClient, createSlackWriteClient, deleteSlackMessage, downloadSlackFile, editSlackMessage, extractSlackToolSend, getSlackMemberInfo, getSlackWriteClient, handleSlackHttpRequest, hasSlackThreadParticipation, inspectSlackAccount, listEnabledSlackAccounts, listSlackAccountIds, listSlackDirectoryGroupsFromConfig, listSlackDirectoryPeersFromConfig, listSlackEmojis, listSlackMessageActions, listSlackPins, listSlackReactions, looksLikeSlackTargetId, mergeSlackAccountConfig, normalizeAllowList, normalizeAllowListLower, normalizeSlackAllowOwnerEntry, normalizeSlackMessagingTarget, normalizeSlackSlug, normalizeSlackWebhookPath, parseSlackBlocksInput, parseSlackTarget, pinSlackMessage, probeSlack, reactSlackMessage, readSlackMessages, recordSlackThreadParticipation, registerSlackHttpHandler, removeOwnSlackReactions, removeSlackReaction, resolveDefaultSlackAccountId, resolveSlackAccount, resolveSlackAllowListMatch, resolveSlackAutoThreadId, resolveSlackChannelId, resolveSlackChannelType, resolveSlackGroupRequireMention, resolveSlackGroupToolPolicy, resolveSlackReplyToMode, resolveSlackRuntimeGroupPolicy, resolveSlackUserAllowed, resolveSlackWebClientOptions, resolveSlackWriteClientOptions, sendSlackMessage, slackPlugin, slackSetupPlugin, unpinSlackMessage, validateSlackBlocksArray };
|