@openclaw/slack 2026.7.2-beta.7 → 2026.7.34
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/dist/.setup/account-configured-DzC407uv.mjs +14 -0
- package/dist/.setup/account-inspect-CcqRNkC3.mjs +79 -0
- package/dist/.setup/account-reply-mode-Bvoq75cS.mjs +15 -0
- package/dist/.setup/accounts-uGn8E6uq.mjs +187 -0
- package/dist/.setup/accounts.runtime-k_V5-EOr.mjs +2 -0
- package/dist/.setup/action-runtime-iq6ZxO_b.mjs +395 -0
- package/dist/.setup/action-runtime.runtime-DXY8CdWJ.mjs +2 -0
- package/dist/.setup/actions-2VEX4Wdz.mjs +950 -0
- package/dist/.setup/actions.runtime-CfX8mK8Y.mjs +2 -0
- package/dist/.setup/approval-handler.runtime-COMbf4Ud.mjs +368 -0
- package/dist/.setup/channel-BqOekthS.mjs +1120 -0
- package/dist/.setup/channel.setup-DBlZCEvc.mjs +73 -0
- package/dist/.setup/client-B6i83rHk.mjs +116 -0
- package/dist/.setup/config-api-DnT9ohtE.mjs +2 -0
- package/dist/.setup/config-schema-DV93lEJ7.mjs +227 -0
- package/dist/.setup/directory-config-DB0OcZzw.mjs +55 -0
- package/dist/.setup/directory-live-O3jkDEJH.mjs +131 -0
- package/dist/.setup/doctor-contract-Dxk57DKz.mjs +147 -0
- package/dist/.setup/format-xuAop9a-.mjs +108 -0
- package/dist/.setup/interactive-replies-BLw4HEPS.mjs +193 -0
- package/dist/.setup/message-tool-api-D2m68v1f.mjs +128 -0
- package/dist/.setup/monitor-jTrujB_u.mjs +13 -0
- package/dist/.setup/outbound-adapter-DwAvZVk8.mjs +273 -0
- package/dist/.setup/pipeline.runtime-qFsXbTJf.mjs +3646 -0
- package/dist/.setup/plugin-routes-C3X0eVaK.mjs +22 -0
- package/dist/.setup/policy-C6VVHqUf.mjs +67 -0
- package/dist/.setup/probe-tmU762D2.mjs +48 -0
- package/dist/.setup/provider-Bjv1R5E2.mjs +4720 -0
- package/dist/.setup/relay-source-DR--lDW8.mjs +289 -0
- package/dist/.setup/replies-BO37R07g.mjs +288 -0
- package/dist/.setup/reply-blocks-Cwu6LYJI.mjs +882 -0
- package/dist/.setup/resolve-allowlist-common-CP8SH0Zf.mjs +43 -0
- package/dist/.setup/resolve-channels-CivvCeZv.mjs +81 -0
- package/dist/.setup/resolve-users-D5Qb64BJ.mjs +113 -0
- package/dist/.setup/rolldown-runtime-D7D4PA-g.mjs +13 -0
- package/dist/.setup/runtime-BOk7xkOl.mjs +8 -0
- package/dist/.setup/runtime-api-BnavgpzD.mjs +9 -0
- package/dist/.setup/runtime-setter-api-C-6lgBvk.mjs +3 -0
- package/dist/.setup/scopes-CYSKlU91.mjs +74 -0
- package/dist/.setup/secret-contract-C3ChHo5A.mjs +181 -0
- package/dist/.setup/secret-contract-api-CcCSHlV7.mjs +3 -0
- package/dist/.setup/security-audit-HMEYeSrJ.mjs +51 -0
- package/dist/.setup/send-DEOvcVM4.mjs +933 -0
- package/dist/.setup/send.runtime-Bmals7DV.mjs +2 -0
- package/dist/.setup/setup-core-uPGudyJH.mjs +344 -0
- package/dist/.setup/setup-plugin-api-DMKdqvij.mjs +3 -0
- package/dist/.setup/setup-surface-_4luZsPQ.mjs +130 -0
- package/dist/.setup/shared-BqyNq0up.mjs +269 -0
- package/dist/.setup/slash-dispatch.runtime-eyQo6mTA.mjs +32 -0
- package/dist/.setup/streaming-compat-DjlgH-Be.mjs +43 -0
- package/dist/.setup/target-parsing-C36VFWHQ.mjs +65 -0
- package/dist/.setup/targets-DnpzC22e.mjs +13 -0
- package/dist/account-inspect-api.js +1 -1
- package/dist/api.js +19 -18
- package/dist/channel-config-api.js +1 -1
- package/dist/channel-plugin-api.js +1 -1
- package/dist/configured-state.js +11 -0
- package/dist/directory-contract-api.js +1 -1
- package/dist/doctor-contract-api.js +1 -1
- package/dist/http-routes-api.js +1 -1
- package/dist/index.js +1 -1
- package/dist/interactive-replies-api.js +2 -0
- package/dist/message-tool-api.js +1 -1
- package/dist/runtime-api.js +13 -13
- package/dist/runtime-setter-api.js +1 -1
- package/dist/secret-contract-api.js +1 -1
- package/dist/security-contract-api.js +1 -1
- package/dist/setup-entry.js +5 -4
- package/dist/setup-plugin-api.js +1 -1
- package/node_modules/@slack/bolt/dist/App.d.ts +19 -4
- package/node_modules/@slack/bolt/dist/App.d.ts.map +1 -1
- package/node_modules/@slack/bolt/dist/App.js +40 -21
- package/node_modules/@slack/bolt/dist/App.js.map +1 -1
- package/node_modules/@slack/bolt/dist/WorkflowStep.d.ts +159 -0
- package/node_modules/@slack/bolt/dist/WorkflowStep.d.ts.map +1 -0
- package/node_modules/@slack/bolt/dist/WorkflowStep.js +217 -0
- package/node_modules/@slack/bolt/dist/WorkflowStep.js.map +1 -0
- package/node_modules/@slack/bolt/dist/context/create-respond.d.ts +3 -3
- package/node_modules/@slack/bolt/dist/context/create-respond.d.ts.map +1 -1
- package/node_modules/@slack/bolt/dist/context/create-respond.js +2 -13
- package/node_modules/@slack/bolt/dist/context/create-respond.js.map +1 -1
- package/node_modules/@slack/bolt/dist/errors.d.ts +8 -6
- package/node_modules/@slack/bolt/dist/errors.d.ts.map +1 -1
- package/node_modules/@slack/bolt/dist/errors.js +11 -11
- package/node_modules/@slack/bolt/dist/errors.js.map +1 -1
- package/node_modules/@slack/bolt/dist/helpers.d.ts.map +1 -1
- package/node_modules/@slack/bolt/dist/helpers.js +2 -1
- package/node_modules/@slack/bolt/dist/helpers.js.map +1 -1
- package/node_modules/@slack/bolt/dist/index.d.ts +1 -0
- package/node_modules/@slack/bolt/dist/index.d.ts.map +1 -1
- package/node_modules/@slack/bolt/dist/index.js +3 -1
- package/node_modules/@slack/bolt/dist/index.js.map +1 -1
- package/node_modules/@slack/bolt/dist/receivers/AwsLambdaReceiver.d.ts +1 -10
- package/node_modules/@slack/bolt/dist/receivers/AwsLambdaReceiver.d.ts.map +1 -1
- package/node_modules/@slack/bolt/dist/receivers/AwsLambdaReceiver.js +1 -5
- package/node_modules/@slack/bolt/dist/receivers/AwsLambdaReceiver.js.map +1 -1
- package/node_modules/@slack/bolt/dist/receivers/HTTPModuleFunctions.d.ts.map +1 -1
- package/node_modules/@slack/bolt/dist/receivers/HTTPModuleFunctions.js +14 -10
- package/node_modules/@slack/bolt/dist/receivers/HTTPModuleFunctions.js.map +1 -1
- package/node_modules/@slack/bolt/dist/receivers/SocketModeFunctions.d.ts.map +1 -1
- package/node_modules/@slack/bolt/dist/receivers/SocketModeFunctions.js +1 -1
- package/node_modules/@slack/bolt/dist/receivers/SocketModeFunctions.js.map +1 -1
- package/node_modules/@slack/bolt/dist/receivers/SocketModeReceiver.d.ts +1 -3
- package/node_modules/@slack/bolt/dist/receivers/SocketModeReceiver.d.ts.map +1 -1
- package/node_modules/@slack/bolt/dist/receivers/SocketModeReceiver.js +1 -2
- package/node_modules/@slack/bolt/dist/receivers/SocketModeReceiver.js.map +1 -1
- package/node_modules/@slack/bolt/dist/types/actions/index.d.ts +4 -2
- package/node_modules/@slack/bolt/dist/types/actions/index.d.ts.map +1 -1
- package/node_modules/@slack/bolt/dist/types/actions/index.js +2 -0
- package/node_modules/@slack/bolt/dist/types/actions/index.js.map +1 -1
- package/node_modules/@slack/bolt/dist/types/actions/workflow-step-edit.d.ts +49 -0
- package/node_modules/@slack/bolt/dist/types/actions/workflow-step-edit.d.ts.map +1 -0
- package/node_modules/@slack/bolt/dist/types/actions/workflow-step-edit.js +3 -0
- package/node_modules/@slack/bolt/dist/types/actions/workflow-step-edit.js.map +1 -0
- package/node_modules/@slack/bolt/dist/types/events/index.d.ts +0 -2
- package/node_modules/@slack/bolt/dist/types/events/index.d.ts.map +1 -1
- package/node_modules/@slack/bolt/dist/types/utilities.d.ts +2 -2
- package/node_modules/@slack/bolt/dist/types/utilities.d.ts.map +1 -1
- package/node_modules/@slack/bolt/dist/types/view/index.d.ts +31 -1
- package/node_modules/@slack/bolt/dist/types/view/index.d.ts.map +1 -1
- package/node_modules/@slack/bolt/node_modules/@slack/logger/README.md +1 -1
- package/node_modules/@slack/bolt/node_modules/@slack/logger/dist/index.js +13 -17
- package/node_modules/@slack/bolt/node_modules/@slack/logger/dist/index.js.map +1 -1
- package/node_modules/@slack/bolt/node_modules/@slack/logger/package.json +7 -6
- package/node_modules/@slack/bolt/node_modules/@slack/oauth/README.md +1 -1
- package/node_modules/@slack/bolt/node_modules/@slack/oauth/dist/errors.d.ts +14 -25
- package/node_modules/@slack/bolt/node_modules/@slack/oauth/dist/errors.d.ts.map +1 -1
- package/node_modules/@slack/bolt/node_modules/@slack/oauth/dist/errors.js +33 -24
- package/node_modules/@slack/bolt/node_modules/@slack/oauth/dist/errors.js.map +1 -1
- package/node_modules/@slack/bolt/node_modules/@slack/oauth/dist/install-provider.js +16 -58
- package/node_modules/@slack/bolt/node_modules/@slack/oauth/dist/install-provider.js.map +1 -1
- package/node_modules/@slack/bolt/node_modules/@slack/oauth/dist/installation-stores/file-store.js +2 -4
- package/node_modules/@slack/bolt/node_modules/@slack/oauth/dist/installation-stores/file-store.js.map +1 -1
- package/node_modules/@slack/bolt/node_modules/@slack/oauth/dist/installation-stores/memory-store.js +16 -3
- package/node_modules/@slack/bolt/node_modules/@slack/oauth/dist/installation-stores/memory-store.js.map +1 -1
- package/node_modules/@slack/bolt/node_modules/@slack/oauth/dist/state-stores/clear-state-store.js +0 -2
- package/node_modules/@slack/bolt/node_modules/@slack/oauth/dist/state-stores/clear-state-store.js.map +1 -1
- package/node_modules/@slack/bolt/node_modules/@slack/oauth/dist/state-stores/file-state-store.js +0 -3
- package/node_modules/@slack/bolt/node_modules/@slack/oauth/dist/state-stores/file-state-store.js.map +1 -1
- package/node_modules/@slack/bolt/node_modules/@slack/oauth/package.json +9 -8
- package/node_modules/@slack/bolt/node_modules/@slack/socket-mode/README.md +221 -0
- package/node_modules/@slack/bolt/node_modules/@slack/socket-mode/dist/package.json +67 -0
- package/node_modules/@slack/bolt/node_modules/@slack/socket-mode/dist/src/SlackWebSocket.d.ts +96 -0
- package/node_modules/@slack/bolt/node_modules/@slack/socket-mode/dist/src/SlackWebSocket.d.ts.map +1 -0
- package/node_modules/@slack/bolt/node_modules/@slack/socket-mode/dist/src/SlackWebSocket.js +242 -0
- package/node_modules/@slack/bolt/node_modules/@slack/socket-mode/dist/src/SlackWebSocket.js.map +1 -0
- package/node_modules/@slack/bolt/node_modules/@slack/socket-mode/dist/src/SocketModeClient.d.ts +98 -0
- package/node_modules/@slack/bolt/node_modules/@slack/socket-mode/dist/src/SocketModeClient.d.ts.map +1 -0
- package/node_modules/@slack/bolt/node_modules/@slack/socket-mode/dist/src/SocketModeClient.js +363 -0
- package/node_modules/@slack/bolt/node_modules/@slack/socket-mode/dist/src/SocketModeClient.js.map +1 -0
- package/node_modules/@slack/bolt/node_modules/@slack/socket-mode/dist/src/SocketModeOptions.d.ts +47 -0
- package/node_modules/@slack/bolt/node_modules/@slack/socket-mode/dist/src/SocketModeOptions.d.ts.map +1 -0
- package/node_modules/@slack/bolt/node_modules/@slack/socket-mode/dist/src/errors.d.ts +60 -0
- package/node_modules/@slack/bolt/node_modules/@slack/socket-mode/dist/src/errors.d.ts.map +1 -0
- package/node_modules/@slack/bolt/node_modules/@slack/socket-mode/dist/src/errors.js +68 -0
- package/node_modules/@slack/bolt/node_modules/@slack/socket-mode/dist/src/errors.js.map +1 -0
- package/node_modules/@slack/bolt/node_modules/@slack/socket-mode/dist/src/index.d.ts +6 -0
- package/node_modules/@slack/bolt/node_modules/@slack/socket-mode/dist/src/index.d.ts.map +1 -0
- package/node_modules/@slack/bolt/node_modules/@slack/socket-mode/dist/src/index.js +13 -0
- package/node_modules/@slack/bolt/node_modules/@slack/socket-mode/dist/src/index.js.map +1 -0
- package/node_modules/@slack/bolt/node_modules/@slack/socket-mode/package.json +67 -0
- package/node_modules/@slack/bolt/node_modules/@types/node/README.md +1 -1
- package/node_modules/@slack/bolt/node_modules/@types/node/fs/promises.d.ts +6 -16
- package/node_modules/@slack/bolt/node_modules/@types/node/package.json +2 -2
- package/node_modules/@slack/bolt/node_modules/@types/ws/README.md +15 -0
- package/node_modules/@slack/bolt/node_modules/@types/ws/index.d.mts +451 -0
- package/node_modules/@slack/bolt/node_modules/@types/ws/index.d.ts +445 -0
- package/node_modules/@slack/bolt/node_modules/@types/ws/package.json +72 -0
- package/node_modules/@slack/bolt/node_modules/agent-base/README.md +145 -0
- package/node_modules/@slack/bolt/node_modules/agent-base/dist/src/index.d.ts +78 -0
- package/node_modules/@slack/bolt/node_modules/agent-base/dist/src/index.js +203 -0
- package/node_modules/@slack/bolt/node_modules/agent-base/dist/src/index.js.map +1 -0
- package/node_modules/@slack/bolt/node_modules/agent-base/dist/src/promisify.d.ts +4 -0
- package/node_modules/@slack/bolt/node_modules/agent-base/dist/src/promisify.js +18 -0
- package/node_modules/@slack/bolt/node_modules/agent-base/dist/src/promisify.js.map +1 -0
- package/node_modules/@slack/bolt/node_modules/agent-base/package.json +64 -0
- package/node_modules/@slack/bolt/node_modules/agent-base/src/index.ts +345 -0
- package/node_modules/@slack/bolt/node_modules/agent-base/src/promisify.ts +33 -0
- package/node_modules/@slack/bolt/node_modules/asynckit/LICENSE +21 -0
- package/node_modules/@slack/bolt/node_modules/asynckit/README.md +233 -0
- package/node_modules/@slack/bolt/node_modules/asynckit/bench.js +76 -0
- package/node_modules/@slack/bolt/node_modules/asynckit/index.js +6 -0
- package/node_modules/@slack/bolt/node_modules/asynckit/lib/abort.js +29 -0
- package/node_modules/@slack/bolt/node_modules/asynckit/lib/async.js +34 -0
- package/node_modules/@slack/bolt/node_modules/asynckit/lib/defer.js +26 -0
- package/node_modules/@slack/bolt/node_modules/asynckit/lib/iterate.js +75 -0
- package/node_modules/@slack/bolt/node_modules/asynckit/lib/readable_asynckit.js +91 -0
- package/node_modules/@slack/bolt/node_modules/asynckit/lib/readable_parallel.js +25 -0
- package/node_modules/@slack/bolt/node_modules/asynckit/lib/readable_serial.js +25 -0
- package/node_modules/@slack/bolt/node_modules/asynckit/lib/readable_serial_ordered.js +29 -0
- package/node_modules/@slack/bolt/node_modules/asynckit/lib/state.js +37 -0
- package/node_modules/@slack/bolt/node_modules/asynckit/lib/streamify.js +141 -0
- package/node_modules/@slack/bolt/node_modules/asynckit/lib/terminator.js +29 -0
- package/node_modules/@slack/bolt/node_modules/asynckit/package.json +63 -0
- package/node_modules/@slack/bolt/node_modules/asynckit/parallel.js +43 -0
- package/node_modules/@slack/bolt/node_modules/asynckit/serial.js +17 -0
- package/node_modules/@slack/bolt/node_modules/asynckit/serialOrdered.js +75 -0
- package/node_modules/@slack/bolt/node_modules/asynckit/stream.js +21 -0
- package/node_modules/@slack/bolt/node_modules/axios/CHANGELOG.md +1934 -0
- package/node_modules/@slack/bolt/node_modules/axios/LICENSE +7 -0
- package/node_modules/@slack/bolt/node_modules/axios/MIGRATION_GUIDE.md +877 -0
- package/node_modules/@slack/bolt/node_modules/axios/README.md +2851 -0
- package/node_modules/@slack/bolt/node_modules/axios/dist/axios.js +5807 -0
- package/node_modules/@slack/bolt/node_modules/axios/dist/axios.min.js +5 -0
- package/node_modules/@slack/bolt/node_modules/axios/dist/axios.min.js.map +1 -0
- package/node_modules/@slack/bolt/node_modules/axios/dist/browser/axios.cjs +5829 -0
- package/node_modules/@slack/bolt/node_modules/axios/dist/esm/axios.js +5850 -0
- package/node_modules/@slack/bolt/node_modules/axios/dist/esm/axios.min.js +3 -0
- package/node_modules/@slack/bolt/node_modules/axios/dist/esm/axios.min.js.map +1 -0
- package/node_modules/@slack/bolt/node_modules/axios/dist/node/axios.cjs +6808 -0
- package/node_modules/@slack/bolt/node_modules/axios/index.d.cts +766 -0
- package/node_modules/@slack/bolt/node_modules/axios/index.d.ts +787 -0
- package/node_modules/@slack/bolt/node_modules/axios/index.js +45 -0
- package/node_modules/@slack/bolt/node_modules/axios/lib/adapters/README.md +36 -0
- package/node_modules/@slack/bolt/node_modules/axios/lib/adapters/adapters.js +132 -0
- package/node_modules/@slack/bolt/node_modules/axios/lib/adapters/fetch.js +696 -0
- package/node_modules/@slack/bolt/node_modules/axios/lib/adapters/http.js +1490 -0
- package/node_modules/@slack/bolt/node_modules/axios/lib/adapters/xhr.js +277 -0
- package/node_modules/@slack/bolt/node_modules/axios/lib/axios.js +89 -0
- package/node_modules/@slack/bolt/node_modules/axios/lib/cancel/CancelToken.js +135 -0
- package/node_modules/@slack/bolt/node_modules/axios/lib/cancel/CanceledError.js +22 -0
- package/node_modules/@slack/bolt/node_modules/axios/lib/cancel/isCancel.js +5 -0
- package/node_modules/@slack/bolt/node_modules/axios/lib/core/Axios.js +306 -0
- package/node_modules/@slack/bolt/node_modules/axios/lib/core/AxiosError.js +219 -0
- package/node_modules/@slack/bolt/node_modules/axios/lib/core/AxiosHeaders.js +474 -0
- package/node_modules/@slack/bolt/node_modules/axios/lib/core/InterceptorManager.js +171 -0
- package/node_modules/@slack/bolt/node_modules/axios/lib/core/README.md +8 -0
- package/node_modules/@slack/bolt/node_modules/axios/lib/core/buildFullPath.js +76 -0
- package/node_modules/@slack/bolt/node_modules/axios/lib/core/dispatchRequest.js +95 -0
- package/node_modules/@slack/bolt/node_modules/axios/lib/core/mergeConfig.js +174 -0
- package/node_modules/@slack/bolt/node_modules/axios/lib/core/methodList.js +17 -0
- package/node_modules/@slack/bolt/node_modules/axios/lib/core/setFormDataHeaders.js +27 -0
- package/node_modules/@slack/bolt/node_modules/axios/lib/core/settle.js +27 -0
- package/node_modules/@slack/bolt/node_modules/axios/lib/core/transformData.js +28 -0
- package/node_modules/@slack/bolt/node_modules/axios/lib/defaults/index.js +178 -0
- package/node_modules/@slack/bolt/node_modules/axios/lib/defaults/transitional.js +10 -0
- package/node_modules/@slack/bolt/node_modules/axios/lib/env/README.md +3 -0
- package/node_modules/@slack/bolt/node_modules/axios/lib/env/classes/FormData.js +2 -0
- package/node_modules/@slack/bolt/node_modules/axios/lib/env/data.js +1 -0
- package/node_modules/@slack/bolt/node_modules/axios/lib/helpers/AxiosTransformStream.js +156 -0
- package/node_modules/@slack/bolt/node_modules/axios/lib/helpers/AxiosURLSearchParams.js +59 -0
- package/node_modules/@slack/bolt/node_modules/axios/lib/helpers/Http2Sessions.js +121 -0
- package/node_modules/@slack/bolt/node_modules/axios/lib/helpers/HttpStatusCode.js +88 -0
- package/node_modules/@slack/bolt/node_modules/axios/lib/helpers/README.md +7 -0
- package/node_modules/@slack/bolt/node_modules/axios/lib/helpers/ZlibHeaderTransformStream.js +29 -0
- package/node_modules/@slack/bolt/node_modules/axios/lib/helpers/bind.js +14 -0
- package/node_modules/@slack/bolt/node_modules/axios/lib/helpers/buildURL.js +69 -0
- package/node_modules/@slack/bolt/node_modules/axios/lib/helpers/callbackify.js +18 -0
- package/node_modules/@slack/bolt/node_modules/axios/lib/helpers/combineURLs.js +23 -0
- package/node_modules/@slack/bolt/node_modules/axios/lib/helpers/composeSignals.js +68 -0
- package/node_modules/@slack/bolt/node_modules/axios/lib/helpers/cookies.js +64 -0
- package/node_modules/@slack/bolt/node_modules/axios/lib/helpers/deprecatedMethod.js +31 -0
- package/node_modules/@slack/bolt/node_modules/axios/lib/helpers/estimateDataURLDecodedBytes.js +166 -0
- package/node_modules/@slack/bolt/node_modules/axios/lib/helpers/formDataToJSON.js +125 -0
- package/node_modules/@slack/bolt/node_modules/axios/lib/helpers/formDataToStream.js +119 -0
- package/node_modules/@slack/bolt/node_modules/axios/lib/helpers/fromDataURI.js +69 -0
- package/node_modules/@slack/bolt/node_modules/axios/lib/helpers/isAbsoluteURL.js +19 -0
- package/node_modules/@slack/bolt/node_modules/axios/lib/helpers/isAxiosError.js +14 -0
- package/node_modules/@slack/bolt/node_modules/axios/lib/helpers/isURLSameOrigin.js +16 -0
- package/node_modules/@slack/bolt/node_modules/axios/lib/helpers/normalizeURLForProtocolCheck.js +24 -0
- package/node_modules/@slack/bolt/node_modules/axios/lib/helpers/null.js +2 -0
- package/node_modules/@slack/bolt/node_modules/axios/lib/helpers/parseHeaders.js +71 -0
- package/node_modules/@slack/bolt/node_modules/axios/lib/helpers/parseProtocol.js +6 -0
- package/node_modules/@slack/bolt/node_modules/axios/lib/helpers/progressEventReducer.js +54 -0
- package/node_modules/@slack/bolt/node_modules/axios/lib/helpers/readBlob.js +15 -0
- package/node_modules/@slack/bolt/node_modules/axios/lib/helpers/resolveConfig.js +107 -0
- package/node_modules/@slack/bolt/node_modules/axios/lib/helpers/sanitizeHeaderValue.js +60 -0
- package/node_modules/@slack/bolt/node_modules/axios/lib/helpers/shouldBypassProxy.js +505 -0
- package/node_modules/@slack/bolt/node_modules/axios/lib/helpers/speedometer.js +55 -0
- package/node_modules/@slack/bolt/node_modules/axios/lib/helpers/spread.js +28 -0
- package/node_modules/@slack/bolt/node_modules/axios/lib/helpers/throttle.js +45 -0
- package/node_modules/@slack/bolt/node_modules/axios/lib/helpers/toFormData.js +279 -0
- package/node_modules/@slack/bolt/node_modules/axios/lib/helpers/toURLEncodedForm.js +19 -0
- package/node_modules/@slack/bolt/node_modules/axios/lib/helpers/trackStream.js +89 -0
- package/node_modules/@slack/bolt/node_modules/axios/lib/helpers/validator.js +112 -0
- package/node_modules/@slack/bolt/node_modules/axios/lib/platform/browser/classes/Blob.js +3 -0
- package/node_modules/@slack/bolt/node_modules/axios/lib/platform/browser/classes/FormData.js +3 -0
- package/node_modules/@slack/bolt/node_modules/axios/lib/platform/browser/classes/URLSearchParams.js +4 -0
- package/node_modules/@slack/bolt/node_modules/axios/lib/platform/browser/index.js +13 -0
- package/node_modules/@slack/bolt/node_modules/axios/lib/platform/common/utils.js +52 -0
- package/node_modules/@slack/bolt/node_modules/axios/lib/platform/index.js +7 -0
- package/node_modules/@slack/bolt/node_modules/axios/lib/platform/node/classes/Buffer.js +11 -0
- package/node_modules/@slack/bolt/node_modules/axios/lib/platform/node/classes/FormData.js +3 -0
- package/node_modules/@slack/bolt/node_modules/axios/lib/platform/node/classes/URLSearchParams.js +4 -0
- package/node_modules/@slack/bolt/node_modules/axios/lib/platform/node/index.js +37 -0
- package/node_modules/@slack/bolt/node_modules/axios/lib/utils.js +1150 -0
- package/node_modules/@slack/bolt/node_modules/axios/package.json +203 -0
- package/node_modules/@slack/bolt/node_modules/combined-stream/License +19 -0
- package/node_modules/@slack/bolt/node_modules/combined-stream/Readme.md +138 -0
- package/node_modules/@slack/bolt/node_modules/combined-stream/lib/combined_stream.js +208 -0
- package/node_modules/@slack/bolt/node_modules/combined-stream/package.json +25 -0
- package/node_modules/@slack/bolt/node_modules/delayed-stream/.npmignore +1 -0
- package/node_modules/@slack/bolt/node_modules/delayed-stream/License +19 -0
- package/node_modules/@slack/bolt/node_modules/delayed-stream/Makefile +7 -0
- package/node_modules/@slack/bolt/node_modules/delayed-stream/Readme.md +141 -0
- package/node_modules/@slack/bolt/node_modules/delayed-stream/lib/delayed_stream.js +107 -0
- package/node_modules/@slack/bolt/node_modules/delayed-stream/package.json +27 -0
- package/node_modules/@slack/bolt/node_modules/es-set-tostringtag/.eslintrc +13 -0
- package/node_modules/@slack/bolt/node_modules/es-set-tostringtag/.nycrc +9 -0
- package/node_modules/@slack/bolt/node_modules/es-set-tostringtag/CHANGELOG.md +67 -0
- package/node_modules/@slack/bolt/node_modules/es-set-tostringtag/LICENSE +21 -0
- package/node_modules/@slack/bolt/node_modules/es-set-tostringtag/README.md +53 -0
- package/node_modules/@slack/bolt/node_modules/es-set-tostringtag/index.d.ts +10 -0
- package/node_modules/@slack/bolt/node_modules/es-set-tostringtag/index.js +35 -0
- package/node_modules/@slack/bolt/node_modules/es-set-tostringtag/package.json +78 -0
- package/node_modules/@slack/bolt/node_modules/es-set-tostringtag/test/index.js +85 -0
- package/node_modules/@slack/bolt/node_modules/es-set-tostringtag/tsconfig.json +9 -0
- package/node_modules/@slack/bolt/node_modules/follow-redirects/LICENSE +18 -0
- package/node_modules/@slack/bolt/node_modules/follow-redirects/README.md +157 -0
- package/node_modules/@slack/bolt/node_modules/follow-redirects/debug.js +15 -0
- package/node_modules/@slack/bolt/node_modules/follow-redirects/http.js +1 -0
- package/node_modules/@slack/bolt/node_modules/follow-redirects/https.js +1 -0
- package/node_modules/@slack/bolt/node_modules/follow-redirects/index.js +709 -0
- package/node_modules/@slack/bolt/node_modules/follow-redirects/package.json +58 -0
- package/node_modules/@slack/bolt/node_modules/form-data/CHANGELOG.md +669 -0
- package/node_modules/@slack/bolt/node_modules/form-data/License +19 -0
- package/node_modules/@slack/bolt/node_modules/form-data/README.md +350 -0
- package/node_modules/@slack/bolt/node_modules/form-data/index.d.ts +51 -0
- package/node_modules/@slack/bolt/node_modules/form-data/lib/browser.js +4 -0
- package/node_modules/@slack/bolt/node_modules/form-data/lib/form_data.js +514 -0
- package/node_modules/@slack/bolt/node_modules/form-data/lib/populate.js +10 -0
- package/node_modules/@slack/bolt/node_modules/form-data/node_modules/mime-db/HISTORY.md +507 -0
- package/node_modules/@slack/bolt/node_modules/form-data/node_modules/mime-db/LICENSE +23 -0
- package/node_modules/@slack/bolt/node_modules/form-data/node_modules/mime-db/README.md +100 -0
- package/node_modules/@slack/bolt/node_modules/form-data/node_modules/mime-db/db.json +8519 -0
- package/node_modules/@slack/bolt/node_modules/form-data/node_modules/mime-db/index.js +12 -0
- package/node_modules/@slack/bolt/node_modules/form-data/node_modules/mime-db/package.json +60 -0
- package/node_modules/@slack/bolt/node_modules/form-data/node_modules/mime-types/HISTORY.md +397 -0
- package/node_modules/@slack/bolt/node_modules/form-data/node_modules/mime-types/LICENSE +23 -0
- package/node_modules/@slack/bolt/node_modules/form-data/node_modules/mime-types/README.md +113 -0
- package/node_modules/@slack/bolt/node_modules/form-data/node_modules/mime-types/index.js +188 -0
- package/node_modules/@slack/bolt/node_modules/form-data/node_modules/mime-types/package.json +44 -0
- package/node_modules/@slack/bolt/node_modules/form-data/package.json +83 -0
- package/node_modules/@slack/bolt/node_modules/has-tostringtag/.eslintrc +5 -0
- package/node_modules/@slack/bolt/node_modules/has-tostringtag/.github/FUNDING.yml +12 -0
- package/node_modules/@slack/bolt/node_modules/has-tostringtag/.nycrc +13 -0
- package/node_modules/@slack/bolt/node_modules/has-tostringtag/CHANGELOG.md +42 -0
- package/node_modules/@slack/bolt/node_modules/has-tostringtag/LICENSE +21 -0
- package/node_modules/@slack/bolt/node_modules/has-tostringtag/README.md +46 -0
- package/node_modules/@slack/bolt/node_modules/has-tostringtag/index.d.ts +3 -0
- package/node_modules/@slack/bolt/node_modules/has-tostringtag/index.js +8 -0
- package/node_modules/@slack/bolt/node_modules/has-tostringtag/package.json +108 -0
- package/node_modules/@slack/bolt/node_modules/has-tostringtag/shams.d.ts +3 -0
- package/node_modules/@slack/bolt/node_modules/has-tostringtag/shams.js +8 -0
- package/node_modules/@slack/bolt/node_modules/has-tostringtag/test/index.js +21 -0
- package/node_modules/@slack/bolt/node_modules/has-tostringtag/test/shams/core-js.js +31 -0
- package/node_modules/@slack/bolt/node_modules/has-tostringtag/test/shams/get-own-property-symbols.js +30 -0
- package/node_modules/@slack/bolt/node_modules/has-tostringtag/test/tests.js +15 -0
- package/node_modules/@slack/bolt/node_modules/has-tostringtag/tsconfig.json +49 -0
- package/node_modules/@slack/bolt/node_modules/https-proxy-agent/README.md +137 -0
- package/node_modules/@slack/bolt/node_modules/https-proxy-agent/dist/agent.d.ts +30 -0
- package/node_modules/@slack/bolt/node_modules/https-proxy-agent/dist/agent.js +177 -0
- package/node_modules/@slack/bolt/node_modules/https-proxy-agent/dist/agent.js.map +1 -0
- package/node_modules/@slack/bolt/node_modules/https-proxy-agent/dist/index.d.ts +23 -0
- package/node_modules/@slack/bolt/node_modules/https-proxy-agent/dist/index.js +14 -0
- package/node_modules/@slack/bolt/node_modules/https-proxy-agent/dist/index.js.map +1 -0
- package/node_modules/@slack/bolt/node_modules/https-proxy-agent/dist/parse-proxy-response.d.ts +7 -0
- package/node_modules/@slack/bolt/node_modules/https-proxy-agent/dist/parse-proxy-response.js +66 -0
- package/node_modules/@slack/bolt/node_modules/https-proxy-agent/dist/parse-proxy-response.js.map +1 -0
- package/node_modules/@slack/bolt/node_modules/https-proxy-agent/package.json +56 -0
- package/node_modules/@slack/bolt/node_modules/iconv-lite/encodings/sbcs-data.js +0 -2
- package/node_modules/@slack/bolt/node_modules/iconv-lite/encodings/utf32.js +3 -10
- package/node_modules/@slack/bolt/node_modules/iconv-lite/package.json +2 -2
- package/node_modules/@slack/bolt/node_modules/iconv-lite/types/encodings.d.ts +0 -2
- package/node_modules/@slack/bolt/node_modules/media-typer/README.md +14 -15
- package/node_modules/@slack/bolt/node_modules/media-typer/index.js +8 -0
- package/node_modules/@slack/bolt/node_modules/media-typer/package.json +12 -16
- package/node_modules/@slack/bolt/node_modules/path-to-regexp/Readme.md +3 -3
- package/node_modules/@slack/bolt/node_modules/path-to-regexp/dist/index.js +158 -135
- package/node_modules/@slack/bolt/node_modules/path-to-regexp/dist/index.js.map +1 -1
- package/node_modules/@slack/bolt/node_modules/path-to-regexp/package.json +2 -2
- package/node_modules/@slack/bolt/node_modules/proxy-addr/HISTORY.md +60 -54
- package/node_modules/@slack/bolt/node_modules/proxy-addr/README.md +1 -1
- package/node_modules/@slack/bolt/node_modules/proxy-addr/index.js +32 -0
- package/node_modules/@slack/bolt/node_modules/proxy-addr/package.json +8 -4
- package/node_modules/@slack/bolt/node_modules/proxy-from-env/LICENSE +20 -0
- package/node_modules/@slack/bolt/node_modules/proxy-from-env/README.md +163 -0
- package/node_modules/@slack/bolt/node_modules/proxy-from-env/index.cjs +105 -0
- package/node_modules/@slack/bolt/node_modules/proxy-from-env/index.js +103 -0
- package/node_modules/@slack/bolt/node_modules/proxy-from-env/package.json +43 -0
- package/node_modules/@slack/bolt/node_modules/qs/CHANGELOG.md +0 -11
- package/node_modules/@slack/bolt/node_modules/qs/dist/qs.js +17 -17
- package/node_modules/@slack/bolt/node_modules/qs/lib/parse.js +8 -19
- package/node_modules/@slack/bolt/node_modules/qs/lib/utils.js +8 -47
- package/node_modules/@slack/bolt/node_modules/qs/package.json +5 -6
- package/node_modules/@slack/bolt/node_modules/qs/test/parse.js +0 -230
- package/node_modules/@slack/bolt/node_modules/qs/test/utils.js +0 -194
- package/node_modules/@slack/bolt/package.json +11 -10
- package/node_modules/@slack/types/README.md +1 -1
- package/node_modules/@slack/types/dist/events/app.d.ts +0 -28
- package/node_modules/@slack/types/dist/events/app.d.ts.map +1 -1
- package/node_modules/@slack/types/dist/events/index.d.ts +2 -2
- package/node_modules/@slack/types/dist/events/index.d.ts.map +1 -1
- package/node_modules/@slack/types/dist/events/index.js.map +1 -1
- package/node_modules/@slack/types/dist/events/message.d.ts +0 -2
- package/node_modules/@slack/types/dist/events/message.d.ts.map +1 -1
- package/node_modules/@slack/types/package.json +3 -3
- package/node_modules/@slack/web-api/README.md +1 -1
- package/node_modules/@slack/web-api/dist/WebClient.d.ts +71 -42
- package/node_modules/@slack/web-api/dist/WebClient.d.ts.map +1 -1
- package/node_modules/@slack/web-api/dist/WebClient.js +248 -180
- package/node_modules/@slack/web-api/dist/WebClient.js.map +1 -1
- package/node_modules/@slack/web-api/dist/chat-stream.js +22 -37
- package/node_modules/@slack/web-api/dist/chat-stream.js.map +1 -1
- package/node_modules/@slack/web-api/dist/errors.d.ts +51 -32
- package/node_modules/@slack/web-api/dist/errors.d.ts.map +1 -1
- package/node_modules/@slack/web-api/dist/errors.js +55 -64
- package/node_modules/@slack/web-api/dist/errors.js.map +1 -1
- package/node_modules/@slack/web-api/dist/file-upload.d.ts +9 -0
- package/node_modules/@slack/web-api/dist/file-upload.d.ts.map +1 -1
- package/node_modules/@slack/web-api/dist/file-upload.js +46 -41
- package/node_modules/@slack/web-api/dist/file-upload.js.map +1 -1
- package/node_modules/@slack/web-api/dist/index.d.ts +2 -2
- package/node_modules/@slack/web-api/dist/index.d.ts.map +1 -1
- package/node_modules/@slack/web-api/dist/index.js +1 -8
- package/node_modules/@slack/web-api/dist/index.js.map +1 -1
- package/node_modules/@slack/web-api/dist/methods.d.ts +38 -2
- package/node_modules/@slack/web-api/dist/methods.d.ts.map +1 -1
- package/node_modules/@slack/web-api/dist/methods.js +1384 -1347
- package/node_modules/@slack/web-api/dist/methods.js.map +1 -1
- package/node_modules/@slack/web-api/dist/types/request/files.d.ts +1 -0
- package/node_modules/@slack/web-api/dist/types/request/files.d.ts.map +1 -1
- package/node_modules/@slack/web-api/dist/types/request/index.d.ts +3 -3
- package/node_modules/@slack/web-api/dist/types/request/index.d.ts.map +1 -1
- package/node_modules/@slack/web-api/dist/types/request/manifest.d.ts +1 -66
- package/node_modules/@slack/web-api/dist/types/request/manifest.d.ts.map +1 -1
- package/node_modules/@slack/web-api/dist/types/request/rtm.d.ts +14 -1
- package/node_modules/@slack/web-api/dist/types/request/rtm.d.ts.map +1 -1
- package/node_modules/@slack/web-api/dist/types/request/workflows.d.ts +29 -0
- package/node_modules/@slack/web-api/dist/types/request/workflows.d.ts.map +1 -1
- package/node_modules/@slack/web-api/node_modules/@slack/logger/README.md +1 -1
- package/node_modules/@slack/web-api/node_modules/@slack/logger/dist/index.js +13 -17
- package/node_modules/@slack/web-api/node_modules/@slack/logger/dist/index.js.map +1 -1
- package/node_modules/@slack/web-api/node_modules/@slack/logger/package.json +7 -6
- package/node_modules/@slack/web-api/node_modules/@types/node/README.md +1 -1
- package/node_modules/@slack/web-api/node_modules/@types/node/fs/promises.d.ts +6 -16
- package/node_modules/@slack/web-api/node_modules/@types/node/package.json +2 -2
- package/node_modules/@slack/web-api/node_modules/agent-base/README.md +145 -0
- package/node_modules/@slack/web-api/node_modules/agent-base/dist/src/index.d.ts +78 -0
- package/node_modules/@slack/web-api/node_modules/agent-base/dist/src/index.js +203 -0
- package/node_modules/@slack/web-api/node_modules/agent-base/dist/src/index.js.map +1 -0
- package/node_modules/@slack/web-api/node_modules/agent-base/dist/src/promisify.d.ts +4 -0
- package/node_modules/@slack/web-api/node_modules/agent-base/dist/src/promisify.js +18 -0
- package/node_modules/@slack/web-api/node_modules/agent-base/dist/src/promisify.js.map +1 -0
- package/node_modules/@slack/web-api/node_modules/agent-base/package.json +64 -0
- package/node_modules/@slack/web-api/node_modules/agent-base/src/index.ts +345 -0
- package/node_modules/@slack/web-api/node_modules/agent-base/src/promisify.ts +33 -0
- package/node_modules/@slack/web-api/node_modules/asynckit/LICENSE +21 -0
- package/node_modules/@slack/web-api/node_modules/asynckit/README.md +233 -0
- package/node_modules/@slack/web-api/node_modules/asynckit/bench.js +76 -0
- package/node_modules/@slack/web-api/node_modules/asynckit/index.js +6 -0
- package/node_modules/@slack/web-api/node_modules/asynckit/lib/abort.js +29 -0
- package/node_modules/@slack/web-api/node_modules/asynckit/lib/async.js +34 -0
- package/node_modules/@slack/web-api/node_modules/asynckit/lib/defer.js +26 -0
- package/node_modules/@slack/web-api/node_modules/asynckit/lib/iterate.js +75 -0
- package/node_modules/@slack/web-api/node_modules/asynckit/lib/readable_asynckit.js +91 -0
- package/node_modules/@slack/web-api/node_modules/asynckit/lib/readable_parallel.js +25 -0
- package/node_modules/@slack/web-api/node_modules/asynckit/lib/readable_serial.js +25 -0
- package/node_modules/@slack/web-api/node_modules/asynckit/lib/readable_serial_ordered.js +29 -0
- package/node_modules/@slack/web-api/node_modules/asynckit/lib/state.js +37 -0
- package/node_modules/@slack/web-api/node_modules/asynckit/lib/streamify.js +141 -0
- package/node_modules/@slack/web-api/node_modules/asynckit/lib/terminator.js +29 -0
- package/node_modules/@slack/web-api/node_modules/asynckit/package.json +63 -0
- package/node_modules/@slack/web-api/node_modules/asynckit/parallel.js +43 -0
- package/node_modules/@slack/web-api/node_modules/asynckit/serial.js +17 -0
- package/node_modules/@slack/web-api/node_modules/asynckit/serialOrdered.js +75 -0
- package/node_modules/@slack/web-api/node_modules/asynckit/stream.js +21 -0
- package/node_modules/@slack/web-api/node_modules/axios/CHANGELOG.md +1934 -0
- package/node_modules/@slack/web-api/node_modules/axios/LICENSE +7 -0
- package/node_modules/@slack/web-api/node_modules/axios/MIGRATION_GUIDE.md +877 -0
- package/node_modules/@slack/web-api/node_modules/axios/README.md +2851 -0
- package/node_modules/@slack/web-api/node_modules/axios/dist/axios.js +5807 -0
- package/node_modules/@slack/web-api/node_modules/axios/dist/axios.min.js +5 -0
- package/node_modules/@slack/web-api/node_modules/axios/dist/axios.min.js.map +1 -0
- package/node_modules/@slack/web-api/node_modules/axios/dist/browser/axios.cjs +5829 -0
- package/node_modules/@slack/web-api/node_modules/axios/dist/esm/axios.js +5850 -0
- package/node_modules/@slack/web-api/node_modules/axios/dist/esm/axios.min.js +3 -0
- package/node_modules/@slack/web-api/node_modules/axios/dist/esm/axios.min.js.map +1 -0
- package/node_modules/@slack/web-api/node_modules/axios/dist/node/axios.cjs +6808 -0
- package/node_modules/@slack/web-api/node_modules/axios/index.d.cts +766 -0
- package/node_modules/@slack/web-api/node_modules/axios/index.d.ts +787 -0
- package/node_modules/@slack/web-api/node_modules/axios/index.js +45 -0
- package/node_modules/@slack/web-api/node_modules/axios/lib/adapters/README.md +36 -0
- package/node_modules/@slack/web-api/node_modules/axios/lib/adapters/adapters.js +132 -0
- package/node_modules/@slack/web-api/node_modules/axios/lib/adapters/fetch.js +696 -0
- package/node_modules/@slack/web-api/node_modules/axios/lib/adapters/http.js +1490 -0
- package/node_modules/@slack/web-api/node_modules/axios/lib/adapters/xhr.js +277 -0
- package/node_modules/@slack/web-api/node_modules/axios/lib/axios.js +89 -0
- package/node_modules/@slack/web-api/node_modules/axios/lib/cancel/CancelToken.js +135 -0
- package/node_modules/@slack/web-api/node_modules/axios/lib/cancel/CanceledError.js +22 -0
- package/node_modules/@slack/web-api/node_modules/axios/lib/cancel/isCancel.js +5 -0
- package/node_modules/@slack/web-api/node_modules/axios/lib/core/Axios.js +306 -0
- package/node_modules/@slack/web-api/node_modules/axios/lib/core/AxiosError.js +219 -0
- package/node_modules/@slack/web-api/node_modules/axios/lib/core/AxiosHeaders.js +474 -0
- package/node_modules/@slack/web-api/node_modules/axios/lib/core/InterceptorManager.js +171 -0
- package/node_modules/@slack/web-api/node_modules/axios/lib/core/README.md +8 -0
- package/node_modules/@slack/web-api/node_modules/axios/lib/core/buildFullPath.js +76 -0
- package/node_modules/@slack/web-api/node_modules/axios/lib/core/dispatchRequest.js +95 -0
- package/node_modules/@slack/web-api/node_modules/axios/lib/core/mergeConfig.js +174 -0
- package/node_modules/@slack/web-api/node_modules/axios/lib/core/methodList.js +17 -0
- package/node_modules/@slack/web-api/node_modules/axios/lib/core/setFormDataHeaders.js +27 -0
- package/node_modules/@slack/web-api/node_modules/axios/lib/core/settle.js +27 -0
- package/node_modules/@slack/web-api/node_modules/axios/lib/core/transformData.js +28 -0
- package/node_modules/@slack/web-api/node_modules/axios/lib/defaults/index.js +178 -0
- package/node_modules/@slack/web-api/node_modules/axios/lib/defaults/transitional.js +10 -0
- package/node_modules/@slack/web-api/node_modules/axios/lib/env/README.md +3 -0
- package/node_modules/@slack/web-api/node_modules/axios/lib/env/classes/FormData.js +2 -0
- package/node_modules/@slack/web-api/node_modules/axios/lib/env/data.js +1 -0
- package/node_modules/@slack/web-api/node_modules/axios/lib/helpers/AxiosTransformStream.js +156 -0
- package/node_modules/@slack/web-api/node_modules/axios/lib/helpers/AxiosURLSearchParams.js +59 -0
- package/node_modules/@slack/web-api/node_modules/axios/lib/helpers/Http2Sessions.js +121 -0
- package/node_modules/@slack/web-api/node_modules/axios/lib/helpers/HttpStatusCode.js +88 -0
- package/node_modules/@slack/web-api/node_modules/axios/lib/helpers/README.md +7 -0
- package/node_modules/@slack/web-api/node_modules/axios/lib/helpers/ZlibHeaderTransformStream.js +29 -0
- package/node_modules/@slack/web-api/node_modules/axios/lib/helpers/bind.js +14 -0
- package/node_modules/@slack/web-api/node_modules/axios/lib/helpers/buildURL.js +69 -0
- package/node_modules/@slack/web-api/node_modules/axios/lib/helpers/callbackify.js +18 -0
- package/node_modules/@slack/web-api/node_modules/axios/lib/helpers/combineURLs.js +23 -0
- package/node_modules/@slack/web-api/node_modules/axios/lib/helpers/composeSignals.js +68 -0
- package/node_modules/@slack/web-api/node_modules/axios/lib/helpers/cookies.js +64 -0
- package/node_modules/@slack/web-api/node_modules/axios/lib/helpers/deprecatedMethod.js +31 -0
- package/node_modules/@slack/web-api/node_modules/axios/lib/helpers/estimateDataURLDecodedBytes.js +166 -0
- package/node_modules/@slack/web-api/node_modules/axios/lib/helpers/formDataToJSON.js +125 -0
- package/node_modules/@slack/web-api/node_modules/axios/lib/helpers/formDataToStream.js +119 -0
- package/node_modules/@slack/web-api/node_modules/axios/lib/helpers/fromDataURI.js +69 -0
- package/node_modules/@slack/web-api/node_modules/axios/lib/helpers/isAbsoluteURL.js +19 -0
- package/node_modules/@slack/web-api/node_modules/axios/lib/helpers/isAxiosError.js +14 -0
- package/node_modules/@slack/web-api/node_modules/axios/lib/helpers/isURLSameOrigin.js +16 -0
- package/node_modules/@slack/web-api/node_modules/axios/lib/helpers/normalizeURLForProtocolCheck.js +24 -0
- package/node_modules/@slack/web-api/node_modules/axios/lib/helpers/null.js +2 -0
- package/node_modules/@slack/web-api/node_modules/axios/lib/helpers/parseHeaders.js +71 -0
- package/node_modules/@slack/web-api/node_modules/axios/lib/helpers/parseProtocol.js +6 -0
- package/node_modules/@slack/web-api/node_modules/axios/lib/helpers/progressEventReducer.js +54 -0
- package/node_modules/@slack/web-api/node_modules/axios/lib/helpers/readBlob.js +15 -0
- package/node_modules/@slack/web-api/node_modules/axios/lib/helpers/resolveConfig.js +107 -0
- package/node_modules/@slack/web-api/node_modules/axios/lib/helpers/sanitizeHeaderValue.js +60 -0
- package/node_modules/@slack/web-api/node_modules/axios/lib/helpers/shouldBypassProxy.js +505 -0
- package/node_modules/@slack/web-api/node_modules/axios/lib/helpers/speedometer.js +55 -0
- package/node_modules/@slack/web-api/node_modules/axios/lib/helpers/spread.js +28 -0
- package/node_modules/@slack/web-api/node_modules/axios/lib/helpers/throttle.js +45 -0
- package/node_modules/@slack/web-api/node_modules/axios/lib/helpers/toFormData.js +279 -0
- package/node_modules/@slack/web-api/node_modules/axios/lib/helpers/toURLEncodedForm.js +19 -0
- package/node_modules/@slack/web-api/node_modules/axios/lib/helpers/trackStream.js +89 -0
- package/node_modules/@slack/web-api/node_modules/axios/lib/helpers/validator.js +112 -0
- package/node_modules/@slack/web-api/node_modules/axios/lib/platform/browser/classes/Blob.js +3 -0
- package/node_modules/@slack/web-api/node_modules/axios/lib/platform/browser/classes/FormData.js +3 -0
- package/node_modules/@slack/web-api/node_modules/axios/lib/platform/browser/classes/URLSearchParams.js +4 -0
- package/node_modules/@slack/web-api/node_modules/axios/lib/platform/browser/index.js +13 -0
- package/node_modules/@slack/web-api/node_modules/axios/lib/platform/common/utils.js +52 -0
- package/node_modules/@slack/web-api/node_modules/axios/lib/platform/index.js +7 -0
- package/node_modules/@slack/web-api/node_modules/axios/lib/platform/node/classes/Buffer.js +11 -0
- package/node_modules/@slack/web-api/node_modules/axios/lib/platform/node/classes/FormData.js +3 -0
- package/node_modules/@slack/web-api/node_modules/axios/lib/platform/node/classes/URLSearchParams.js +4 -0
- package/node_modules/@slack/web-api/node_modules/axios/lib/platform/node/index.js +37 -0
- package/node_modules/@slack/web-api/node_modules/axios/lib/utils.js +1150 -0
- package/node_modules/@slack/web-api/node_modules/axios/package.json +203 -0
- package/node_modules/@slack/web-api/node_modules/call-bind-apply-helpers/.eslintrc +17 -0
- package/node_modules/@slack/web-api/node_modules/call-bind-apply-helpers/.github/FUNDING.yml +12 -0
- package/node_modules/@slack/web-api/node_modules/call-bind-apply-helpers/.nycrc +9 -0
- package/node_modules/@slack/web-api/node_modules/call-bind-apply-helpers/CHANGELOG.md +30 -0
- package/node_modules/@slack/web-api/node_modules/call-bind-apply-helpers/LICENSE +21 -0
- package/node_modules/@slack/web-api/node_modules/call-bind-apply-helpers/README.md +62 -0
- package/node_modules/@slack/web-api/node_modules/call-bind-apply-helpers/actualApply.d.ts +1 -0
- package/node_modules/@slack/web-api/node_modules/call-bind-apply-helpers/actualApply.js +10 -0
- package/node_modules/@slack/web-api/node_modules/call-bind-apply-helpers/applyBind.d.ts +19 -0
- package/node_modules/@slack/web-api/node_modules/call-bind-apply-helpers/applyBind.js +10 -0
- package/node_modules/@slack/web-api/node_modules/call-bind-apply-helpers/functionApply.d.ts +1 -0
- package/node_modules/@slack/web-api/node_modules/call-bind-apply-helpers/functionApply.js +4 -0
- package/node_modules/@slack/web-api/node_modules/call-bind-apply-helpers/functionCall.d.ts +1 -0
- package/node_modules/@slack/web-api/node_modules/call-bind-apply-helpers/functionCall.js +4 -0
- package/node_modules/@slack/web-api/node_modules/call-bind-apply-helpers/index.d.ts +64 -0
- package/node_modules/@slack/web-api/node_modules/call-bind-apply-helpers/index.js +15 -0
- package/node_modules/@slack/web-api/node_modules/call-bind-apply-helpers/package.json +85 -0
- package/node_modules/@slack/web-api/node_modules/call-bind-apply-helpers/reflectApply.d.ts +3 -0
- package/node_modules/@slack/web-api/node_modules/call-bind-apply-helpers/reflectApply.js +4 -0
- package/node_modules/@slack/web-api/node_modules/call-bind-apply-helpers/test/index.js +63 -0
- package/node_modules/@slack/web-api/node_modules/call-bind-apply-helpers/tsconfig.json +9 -0
- package/node_modules/@slack/web-api/node_modules/combined-stream/License +19 -0
- package/node_modules/@slack/web-api/node_modules/combined-stream/Readme.md +138 -0
- package/node_modules/@slack/web-api/node_modules/combined-stream/lib/combined_stream.js +208 -0
- package/node_modules/@slack/web-api/node_modules/combined-stream/package.json +25 -0
- package/node_modules/@slack/web-api/node_modules/debug/LICENSE +20 -0
- package/node_modules/@slack/web-api/node_modules/debug/README.md +481 -0
- package/node_modules/@slack/web-api/node_modules/debug/package.json +64 -0
- package/node_modules/@slack/web-api/node_modules/debug/src/browser.js +272 -0
- package/node_modules/@slack/web-api/node_modules/debug/src/common.js +292 -0
- package/node_modules/@slack/web-api/node_modules/debug/src/index.js +10 -0
- package/node_modules/@slack/web-api/node_modules/debug/src/node.js +263 -0
- package/node_modules/@slack/web-api/node_modules/delayed-stream/.npmignore +1 -0
- package/node_modules/@slack/web-api/node_modules/delayed-stream/License +19 -0
- package/node_modules/@slack/web-api/node_modules/delayed-stream/Makefile +7 -0
- package/node_modules/@slack/web-api/node_modules/delayed-stream/Readme.md +141 -0
- package/node_modules/@slack/web-api/node_modules/delayed-stream/lib/delayed_stream.js +107 -0
- package/node_modules/@slack/web-api/node_modules/delayed-stream/package.json +27 -0
- package/node_modules/@slack/web-api/node_modules/dunder-proto/.eslintrc +5 -0
- package/node_modules/@slack/web-api/node_modules/dunder-proto/.github/FUNDING.yml +12 -0
- package/node_modules/@slack/web-api/node_modules/dunder-proto/.nycrc +13 -0
- package/node_modules/@slack/web-api/node_modules/dunder-proto/CHANGELOG.md +24 -0
- package/node_modules/@slack/web-api/node_modules/dunder-proto/LICENSE +21 -0
- package/node_modules/@slack/web-api/node_modules/dunder-proto/README.md +54 -0
- package/node_modules/@slack/web-api/node_modules/dunder-proto/get.d.ts +5 -0
- package/node_modules/@slack/web-api/node_modules/dunder-proto/get.js +30 -0
- package/node_modules/@slack/web-api/node_modules/dunder-proto/package.json +76 -0
- package/node_modules/@slack/web-api/node_modules/dunder-proto/set.d.ts +5 -0
- package/node_modules/@slack/web-api/node_modules/dunder-proto/set.js +35 -0
- package/node_modules/@slack/web-api/node_modules/dunder-proto/test/get.js +34 -0
- package/node_modules/@slack/web-api/node_modules/dunder-proto/test/index.js +4 -0
- package/node_modules/@slack/web-api/node_modules/dunder-proto/test/set.js +50 -0
- package/node_modules/@slack/web-api/node_modules/dunder-proto/tsconfig.json +9 -0
- package/node_modules/@slack/web-api/node_modules/es-define-property/.eslintrc +13 -0
- package/node_modules/@slack/web-api/node_modules/es-define-property/.github/FUNDING.yml +12 -0
- package/node_modules/@slack/web-api/node_modules/es-define-property/.nycrc +9 -0
- package/node_modules/@slack/web-api/node_modules/es-define-property/CHANGELOG.md +29 -0
- package/node_modules/@slack/web-api/node_modules/es-define-property/LICENSE +21 -0
- package/node_modules/@slack/web-api/node_modules/es-define-property/README.md +49 -0
- package/node_modules/@slack/web-api/node_modules/es-define-property/index.d.ts +3 -0
- package/node_modules/@slack/web-api/node_modules/es-define-property/index.js +14 -0
- package/node_modules/@slack/web-api/node_modules/es-define-property/package.json +81 -0
- package/node_modules/@slack/web-api/node_modules/es-define-property/test/index.js +56 -0
- package/node_modules/@slack/web-api/node_modules/es-define-property/tsconfig.json +10 -0
- package/node_modules/@slack/web-api/node_modules/es-errors/.eslintrc +5 -0
- package/node_modules/@slack/web-api/node_modules/es-errors/.github/FUNDING.yml +12 -0
- package/node_modules/@slack/web-api/node_modules/es-errors/CHANGELOG.md +40 -0
- package/node_modules/@slack/web-api/node_modules/es-errors/LICENSE +21 -0
- package/node_modules/@slack/web-api/node_modules/es-errors/README.md +55 -0
- package/node_modules/@slack/web-api/node_modules/es-errors/eval.d.ts +3 -0
- package/node_modules/@slack/web-api/node_modules/es-errors/eval.js +4 -0
- package/node_modules/@slack/web-api/node_modules/es-errors/index.d.ts +3 -0
- package/node_modules/@slack/web-api/node_modules/es-errors/index.js +4 -0
- package/node_modules/@slack/web-api/node_modules/es-errors/package.json +80 -0
- package/node_modules/@slack/web-api/node_modules/es-errors/range.d.ts +3 -0
- package/node_modules/@slack/web-api/node_modules/es-errors/range.js +4 -0
- package/node_modules/@slack/web-api/node_modules/es-errors/ref.d.ts +3 -0
- package/node_modules/@slack/web-api/node_modules/es-errors/ref.js +4 -0
- package/node_modules/@slack/web-api/node_modules/es-errors/syntax.d.ts +3 -0
- package/node_modules/@slack/web-api/node_modules/es-errors/syntax.js +4 -0
- package/node_modules/@slack/web-api/node_modules/es-errors/test/index.js +19 -0
- package/node_modules/@slack/web-api/node_modules/es-errors/tsconfig.json +49 -0
- package/node_modules/@slack/web-api/node_modules/es-errors/type.d.ts +3 -0
- package/node_modules/@slack/web-api/node_modules/es-errors/type.js +4 -0
- package/node_modules/@slack/web-api/node_modules/es-errors/uri.d.ts +3 -0
- package/node_modules/@slack/web-api/node_modules/es-errors/uri.js +4 -0
- package/node_modules/@slack/web-api/node_modules/es-object-atoms/.eslintrc +16 -0
- package/node_modules/@slack/web-api/node_modules/es-object-atoms/.github/FUNDING.yml +12 -0
- package/node_modules/@slack/web-api/node_modules/es-object-atoms/CHANGELOG.md +44 -0
- package/node_modules/@slack/web-api/node_modules/es-object-atoms/LICENSE +21 -0
- package/node_modules/@slack/web-api/node_modules/es-object-atoms/README.md +63 -0
- package/node_modules/@slack/web-api/node_modules/es-object-atoms/RequireObjectCoercible.d.ts +3 -0
- package/node_modules/@slack/web-api/node_modules/es-object-atoms/RequireObjectCoercible.js +11 -0
- package/node_modules/@slack/web-api/node_modules/es-object-atoms/ToObject.d.ts +7 -0
- package/node_modules/@slack/web-api/node_modules/es-object-atoms/ToObject.js +10 -0
- package/node_modules/@slack/web-api/node_modules/es-object-atoms/index.d.ts +3 -0
- package/node_modules/@slack/web-api/node_modules/es-object-atoms/index.js +4 -0
- package/node_modules/@slack/web-api/node_modules/es-object-atoms/isObject.d.ts +3 -0
- package/node_modules/@slack/web-api/node_modules/es-object-atoms/isObject.js +6 -0
- package/node_modules/@slack/web-api/node_modules/es-object-atoms/package.json +79 -0
- package/node_modules/@slack/web-api/node_modules/es-object-atoms/test/index.js +38 -0
- package/node_modules/@slack/web-api/node_modules/es-object-atoms/tsconfig.json +7 -0
- package/node_modules/@slack/web-api/node_modules/es-set-tostringtag/.eslintrc +13 -0
- package/node_modules/@slack/web-api/node_modules/es-set-tostringtag/.nycrc +9 -0
- package/node_modules/@slack/web-api/node_modules/es-set-tostringtag/CHANGELOG.md +67 -0
- package/node_modules/@slack/web-api/node_modules/es-set-tostringtag/LICENSE +21 -0
- package/node_modules/@slack/web-api/node_modules/es-set-tostringtag/README.md +53 -0
- package/node_modules/@slack/web-api/node_modules/es-set-tostringtag/index.d.ts +10 -0
- package/node_modules/@slack/web-api/node_modules/es-set-tostringtag/index.js +35 -0
- package/node_modules/@slack/web-api/node_modules/es-set-tostringtag/package.json +78 -0
- package/node_modules/@slack/web-api/node_modules/es-set-tostringtag/test/index.js +85 -0
- package/node_modules/@slack/web-api/node_modules/es-set-tostringtag/tsconfig.json +9 -0
- package/node_modules/@slack/web-api/node_modules/follow-redirects/LICENSE +18 -0
- package/node_modules/@slack/web-api/node_modules/follow-redirects/README.md +157 -0
- package/node_modules/@slack/web-api/node_modules/follow-redirects/debug.js +15 -0
- package/node_modules/@slack/web-api/node_modules/follow-redirects/http.js +1 -0
- package/node_modules/@slack/web-api/node_modules/follow-redirects/https.js +1 -0
- package/node_modules/@slack/web-api/node_modules/follow-redirects/index.js +709 -0
- package/node_modules/@slack/web-api/node_modules/follow-redirects/package.json +58 -0
- package/node_modules/@slack/web-api/node_modules/form-data/CHANGELOG.md +669 -0
- package/node_modules/@slack/web-api/node_modules/form-data/License +19 -0
- package/node_modules/@slack/web-api/node_modules/form-data/README.md +350 -0
- package/node_modules/@slack/web-api/node_modules/form-data/index.d.ts +51 -0
- package/node_modules/@slack/web-api/node_modules/form-data/lib/browser.js +4 -0
- package/node_modules/@slack/web-api/node_modules/form-data/lib/form_data.js +514 -0
- package/node_modules/@slack/web-api/node_modules/form-data/lib/populate.js +10 -0
- package/node_modules/@slack/web-api/node_modules/form-data/package.json +83 -0
- package/node_modules/@slack/web-api/node_modules/function-bind/.eslintrc +21 -0
- package/node_modules/@slack/web-api/node_modules/function-bind/.github/FUNDING.yml +12 -0
- package/node_modules/@slack/web-api/node_modules/function-bind/.github/SECURITY.md +3 -0
- package/node_modules/@slack/web-api/node_modules/function-bind/.nycrc +13 -0
- package/node_modules/@slack/web-api/node_modules/function-bind/CHANGELOG.md +136 -0
- package/node_modules/@slack/web-api/node_modules/function-bind/LICENSE +20 -0
- package/node_modules/@slack/web-api/node_modules/function-bind/README.md +46 -0
- package/node_modules/@slack/web-api/node_modules/function-bind/implementation.js +84 -0
- package/node_modules/@slack/web-api/node_modules/function-bind/index.js +5 -0
- package/node_modules/@slack/web-api/node_modules/function-bind/package.json +87 -0
- package/node_modules/@slack/web-api/node_modules/function-bind/test/.eslintrc +9 -0
- package/node_modules/@slack/web-api/node_modules/function-bind/test/index.js +252 -0
- package/node_modules/@slack/web-api/node_modules/get-intrinsic/.eslintrc +42 -0
- package/node_modules/@slack/web-api/node_modules/get-intrinsic/.github/FUNDING.yml +12 -0
- package/node_modules/@slack/web-api/node_modules/get-intrinsic/.nycrc +9 -0
- package/node_modules/@slack/web-api/node_modules/get-intrinsic/CHANGELOG.md +186 -0
- package/node_modules/@slack/web-api/node_modules/get-intrinsic/LICENSE +21 -0
- package/node_modules/@slack/web-api/node_modules/get-intrinsic/README.md +71 -0
- package/node_modules/@slack/web-api/node_modules/get-intrinsic/index.js +378 -0
- package/node_modules/@slack/web-api/node_modules/get-intrinsic/package.json +97 -0
- package/node_modules/@slack/web-api/node_modules/get-intrinsic/test/GetIntrinsic.js +274 -0
- package/node_modules/@slack/web-api/node_modules/get-proto/.eslintrc +10 -0
- package/node_modules/@slack/web-api/node_modules/get-proto/.github/FUNDING.yml +12 -0
- package/node_modules/@slack/web-api/node_modules/get-proto/.nycrc +9 -0
- package/node_modules/@slack/web-api/node_modules/get-proto/CHANGELOG.md +21 -0
- package/node_modules/@slack/web-api/node_modules/get-proto/LICENSE +21 -0
- package/node_modules/@slack/web-api/node_modules/get-proto/Object.getPrototypeOf.d.ts +5 -0
- package/node_modules/@slack/web-api/node_modules/get-proto/Object.getPrototypeOf.js +6 -0
- package/node_modules/@slack/web-api/node_modules/get-proto/README.md +50 -0
- package/node_modules/@slack/web-api/node_modules/get-proto/Reflect.getPrototypeOf.d.ts +3 -0
- package/node_modules/@slack/web-api/node_modules/get-proto/Reflect.getPrototypeOf.js +4 -0
- package/node_modules/@slack/web-api/node_modules/get-proto/index.d.ts +5 -0
- package/node_modules/@slack/web-api/node_modules/get-proto/index.js +27 -0
- package/node_modules/@slack/web-api/node_modules/get-proto/package.json +81 -0
- package/node_modules/@slack/web-api/node_modules/get-proto/test/index.js +68 -0
- package/node_modules/@slack/web-api/node_modules/get-proto/tsconfig.json +9 -0
- package/node_modules/@slack/web-api/node_modules/gopd/.eslintrc +16 -0
- package/node_modules/@slack/web-api/node_modules/gopd/.github/FUNDING.yml +12 -0
- package/node_modules/@slack/web-api/node_modules/gopd/CHANGELOG.md +45 -0
- package/node_modules/@slack/web-api/node_modules/gopd/LICENSE +21 -0
- package/node_modules/@slack/web-api/node_modules/gopd/README.md +40 -0
- package/node_modules/@slack/web-api/node_modules/gopd/gOPD.d.ts +1 -0
- package/node_modules/@slack/web-api/node_modules/gopd/gOPD.js +4 -0
- package/node_modules/@slack/web-api/node_modules/gopd/index.d.ts +5 -0
- package/node_modules/@slack/web-api/node_modules/gopd/index.js +15 -0
- package/node_modules/@slack/web-api/node_modules/gopd/package.json +77 -0
- package/node_modules/@slack/web-api/node_modules/gopd/test/index.js +36 -0
- package/node_modules/@slack/web-api/node_modules/gopd/tsconfig.json +9 -0
- package/node_modules/@slack/web-api/node_modules/has-symbols/.eslintrc +11 -0
- package/node_modules/@slack/web-api/node_modules/has-symbols/.github/FUNDING.yml +12 -0
- package/node_modules/@slack/web-api/node_modules/has-symbols/.nycrc +9 -0
- package/node_modules/@slack/web-api/node_modules/has-symbols/CHANGELOG.md +91 -0
- package/node_modules/@slack/web-api/node_modules/has-symbols/LICENSE +21 -0
- package/node_modules/@slack/web-api/node_modules/has-symbols/README.md +46 -0
- package/node_modules/@slack/web-api/node_modules/has-symbols/index.d.ts +3 -0
- package/node_modules/@slack/web-api/node_modules/has-symbols/index.js +14 -0
- package/node_modules/@slack/web-api/node_modules/has-symbols/package.json +111 -0
- package/node_modules/@slack/web-api/node_modules/has-symbols/shams.d.ts +3 -0
- package/node_modules/@slack/web-api/node_modules/has-symbols/shams.js +45 -0
- package/node_modules/@slack/web-api/node_modules/has-symbols/test/index.js +22 -0
- package/node_modules/@slack/web-api/node_modules/has-symbols/test/shams/core-js.js +29 -0
- package/node_modules/@slack/web-api/node_modules/has-symbols/test/shams/get-own-property-symbols.js +29 -0
- package/node_modules/@slack/web-api/node_modules/has-symbols/test/tests.js +58 -0
- package/node_modules/@slack/web-api/node_modules/has-symbols/tsconfig.json +10 -0
- package/node_modules/@slack/web-api/node_modules/has-tostringtag/.eslintrc +5 -0
- package/node_modules/@slack/web-api/node_modules/has-tostringtag/.github/FUNDING.yml +12 -0
- package/node_modules/@slack/web-api/node_modules/has-tostringtag/.nycrc +13 -0
- package/node_modules/@slack/web-api/node_modules/has-tostringtag/CHANGELOG.md +42 -0
- package/node_modules/@slack/web-api/node_modules/has-tostringtag/LICENSE +21 -0
- package/node_modules/@slack/web-api/node_modules/has-tostringtag/README.md +46 -0
- package/node_modules/@slack/web-api/node_modules/has-tostringtag/index.d.ts +3 -0
- package/node_modules/@slack/web-api/node_modules/has-tostringtag/index.js +8 -0
- package/node_modules/@slack/web-api/node_modules/has-tostringtag/package.json +108 -0
- package/node_modules/@slack/web-api/node_modules/has-tostringtag/shams.d.ts +3 -0
- package/node_modules/@slack/web-api/node_modules/has-tostringtag/shams.js +8 -0
- package/node_modules/@slack/web-api/node_modules/has-tostringtag/test/index.js +21 -0
- package/node_modules/@slack/web-api/node_modules/has-tostringtag/test/shams/core-js.js +31 -0
- package/node_modules/@slack/web-api/node_modules/has-tostringtag/test/shams/get-own-property-symbols.js +30 -0
- package/node_modules/@slack/web-api/node_modules/has-tostringtag/test/tests.js +15 -0
- package/node_modules/@slack/web-api/node_modules/has-tostringtag/tsconfig.json +49 -0
- package/node_modules/@slack/web-api/node_modules/hasown/.github/FUNDING.yml +12 -0
- package/node_modules/@slack/web-api/node_modules/hasown/.nycrc +13 -0
- package/node_modules/@slack/web-api/node_modules/hasown/CHANGELOG.md +58 -0
- package/node_modules/@slack/web-api/node_modules/hasown/LICENSE +21 -0
- package/node_modules/@slack/web-api/node_modules/hasown/README.md +40 -0
- package/node_modules/@slack/web-api/node_modules/hasown/eslint.config.mjs +6 -0
- package/node_modules/@slack/web-api/node_modules/hasown/index.d.ts +3 -0
- package/node_modules/@slack/web-api/node_modules/hasown/index.js +8 -0
- package/node_modules/@slack/web-api/node_modules/hasown/package.json +91 -0
- package/node_modules/@slack/web-api/node_modules/hasown/tsconfig.json +6 -0
- package/node_modules/@slack/web-api/node_modules/https-proxy-agent/README.md +137 -0
- package/node_modules/@slack/web-api/node_modules/https-proxy-agent/dist/agent.d.ts +30 -0
- package/node_modules/@slack/web-api/node_modules/https-proxy-agent/dist/agent.js +177 -0
- package/node_modules/@slack/web-api/node_modules/https-proxy-agent/dist/agent.js.map +1 -0
- package/node_modules/@slack/web-api/node_modules/https-proxy-agent/dist/index.d.ts +23 -0
- package/node_modules/@slack/web-api/node_modules/https-proxy-agent/dist/index.js +14 -0
- package/node_modules/@slack/web-api/node_modules/https-proxy-agent/dist/index.js.map +1 -0
- package/node_modules/@slack/web-api/node_modules/https-proxy-agent/dist/parse-proxy-response.d.ts +7 -0
- package/node_modules/@slack/web-api/node_modules/https-proxy-agent/dist/parse-proxy-response.js +66 -0
- package/node_modules/@slack/web-api/node_modules/https-proxy-agent/dist/parse-proxy-response.js.map +1 -0
- package/node_modules/@slack/web-api/node_modules/https-proxy-agent/package.json +56 -0
- package/node_modules/@slack/web-api/node_modules/is-electron/LICENSE +21 -0
- package/node_modules/@slack/web-api/node_modules/is-electron/README.md +25 -0
- package/node_modules/@slack/web-api/node_modules/is-electron/index.d.ts +2 -0
- package/node_modules/@slack/web-api/node_modules/is-electron/index.js +21 -0
- package/node_modules/@slack/web-api/node_modules/is-electron/package.json +34 -0
- package/node_modules/@slack/web-api/node_modules/is-stream/index.d.ts +79 -0
- package/node_modules/@slack/web-api/node_modules/is-stream/index.js +28 -0
- package/node_modules/@slack/web-api/node_modules/is-stream/package.json +42 -0
- package/node_modules/@slack/web-api/node_modules/is-stream/readme.md +60 -0
- package/node_modules/@slack/web-api/node_modules/math-intrinsics/.eslintrc +16 -0
- package/node_modules/@slack/web-api/node_modules/math-intrinsics/.github/FUNDING.yml +12 -0
- package/node_modules/@slack/web-api/node_modules/math-intrinsics/CHANGELOG.md +24 -0
- package/node_modules/@slack/web-api/node_modules/math-intrinsics/LICENSE +21 -0
- package/node_modules/@slack/web-api/node_modules/math-intrinsics/README.md +50 -0
- package/node_modules/@slack/web-api/node_modules/math-intrinsics/abs.d.ts +1 -0
- package/node_modules/@slack/web-api/node_modules/math-intrinsics/abs.js +4 -0
- package/node_modules/@slack/web-api/node_modules/math-intrinsics/constants/maxArrayLength.d.ts +3 -0
- package/node_modules/@slack/web-api/node_modules/math-intrinsics/constants/maxArrayLength.js +4 -0
- package/node_modules/@slack/web-api/node_modules/math-intrinsics/constants/maxSafeInteger.d.ts +3 -0
- package/node_modules/@slack/web-api/node_modules/math-intrinsics/constants/maxSafeInteger.js +5 -0
- package/node_modules/@slack/web-api/node_modules/math-intrinsics/constants/maxValue.d.ts +3 -0
- package/node_modules/@slack/web-api/node_modules/math-intrinsics/constants/maxValue.js +5 -0
- package/node_modules/@slack/web-api/node_modules/math-intrinsics/floor.d.ts +1 -0
- package/node_modules/@slack/web-api/node_modules/math-intrinsics/floor.js +4 -0
- package/node_modules/@slack/web-api/node_modules/math-intrinsics/isFinite.d.ts +3 -0
- package/node_modules/@slack/web-api/node_modules/math-intrinsics/isFinite.js +12 -0
- package/node_modules/@slack/web-api/node_modules/math-intrinsics/isInteger.d.ts +3 -0
- package/node_modules/@slack/web-api/node_modules/math-intrinsics/isInteger.js +16 -0
- package/node_modules/@slack/web-api/node_modules/math-intrinsics/isNaN.d.ts +1 -0
- package/node_modules/@slack/web-api/node_modules/math-intrinsics/isNaN.js +6 -0
- package/node_modules/@slack/web-api/node_modules/math-intrinsics/isNegativeZero.d.ts +3 -0
- package/node_modules/@slack/web-api/node_modules/math-intrinsics/isNegativeZero.js +6 -0
- package/node_modules/@slack/web-api/node_modules/math-intrinsics/max.d.ts +1 -0
- package/node_modules/@slack/web-api/node_modules/math-intrinsics/max.js +4 -0
- package/node_modules/@slack/web-api/node_modules/math-intrinsics/min.d.ts +1 -0
- package/node_modules/@slack/web-api/node_modules/math-intrinsics/min.js +4 -0
- package/node_modules/@slack/web-api/node_modules/math-intrinsics/mod.d.ts +3 -0
- package/node_modules/@slack/web-api/node_modules/math-intrinsics/mod.js +9 -0
- package/node_modules/@slack/web-api/node_modules/math-intrinsics/package.json +86 -0
- package/node_modules/@slack/web-api/node_modules/math-intrinsics/pow.d.ts +1 -0
- package/node_modules/@slack/web-api/node_modules/math-intrinsics/pow.js +4 -0
- package/node_modules/@slack/web-api/node_modules/math-intrinsics/round.d.ts +1 -0
- package/node_modules/@slack/web-api/node_modules/math-intrinsics/round.js +4 -0
- package/node_modules/@slack/web-api/node_modules/math-intrinsics/sign.d.ts +3 -0
- package/node_modules/@slack/web-api/node_modules/math-intrinsics/sign.js +11 -0
- package/node_modules/@slack/web-api/node_modules/math-intrinsics/test/index.js +192 -0
- package/node_modules/@slack/web-api/node_modules/math-intrinsics/tsconfig.json +3 -0
- package/node_modules/@slack/web-api/node_modules/mime-db/HISTORY.md +507 -0
- package/node_modules/@slack/web-api/node_modules/mime-db/LICENSE +23 -0
- package/node_modules/@slack/web-api/node_modules/mime-db/README.md +100 -0
- package/node_modules/@slack/web-api/node_modules/mime-db/db.json +8519 -0
- package/node_modules/@slack/web-api/node_modules/mime-db/index.js +12 -0
- package/node_modules/@slack/web-api/node_modules/mime-db/package.json +60 -0
- package/node_modules/@slack/web-api/node_modules/mime-types/HISTORY.md +397 -0
- package/node_modules/@slack/web-api/node_modules/mime-types/LICENSE +23 -0
- package/node_modules/@slack/web-api/node_modules/mime-types/README.md +113 -0
- package/node_modules/@slack/web-api/node_modules/mime-types/index.js +188 -0
- package/node_modules/@slack/web-api/node_modules/mime-types/package.json +44 -0
- package/node_modules/@slack/web-api/node_modules/ms/index.js +162 -0
- package/node_modules/@slack/web-api/node_modules/ms/license.md +21 -0
- package/node_modules/@slack/web-api/node_modules/ms/package.json +38 -0
- package/node_modules/@slack/web-api/node_modules/ms/readme.md +59 -0
- package/node_modules/@slack/web-api/node_modules/proxy-from-env/LICENSE +20 -0
- package/node_modules/@slack/web-api/node_modules/proxy-from-env/README.md +163 -0
- package/node_modules/@slack/web-api/node_modules/proxy-from-env/index.cjs +105 -0
- package/node_modules/@slack/web-api/node_modules/proxy-from-env/index.js +103 -0
- package/node_modules/@slack/web-api/node_modules/proxy-from-env/package.json +43 -0
- package/node_modules/@slack/web-api/node_modules/safe-buffer/LICENSE +21 -0
- package/node_modules/@slack/web-api/node_modules/safe-buffer/README.md +584 -0
- package/node_modules/@slack/web-api/node_modules/safe-buffer/index.d.ts +187 -0
- package/node_modules/@slack/web-api/node_modules/safe-buffer/index.js +65 -0
- package/node_modules/@slack/web-api/node_modules/safe-buffer/package.json +51 -0
- package/node_modules/@slack/web-api/package.json +10 -6
- package/node_modules/typebox/build/compile/validator.d.mts +4 -1
- package/node_modules/typebox/build/guard/guard.d.mts +1 -1
- package/node_modules/typebox/build/guard/guard.mjs +2 -5
- package/node_modules/typebox/build/guard/string.mjs +4 -16
- package/node_modules/typebox/build/schema/engine/_functions.mjs +15 -34
- package/node_modules/typebox/build/type/action/readonly_object.d.mts +0 -5
- package/node_modules/typebox/build/type/action/readonly_object.mjs +0 -8
- package/node_modules/typebox/build/typebox.d.mts +1 -1
- package/node_modules/typebox/build/typebox.mjs +1 -1
- package/node_modules/typebox/package.json +1 -1
- package/node_modules/typebox/readme.md +32 -29
- package/node_modules/ws/lib/permessage-deflate.js +3 -1
- package/node_modules/ws/package.json +1 -1
- package/openclaw.plugin.json +1390 -1351
- package/package.json +19 -109
- package/dist/account-configured-BwfXBo_F.js +0 -14
- package/dist/account-inspect-DEKpg9Ip.js +0 -89
- package/dist/account-reply-mode-DrUXogvO.js +0 -14
- package/dist/accounts-CHAeNZOX.js +0 -186
- package/dist/accounts.runtime-BHD4Ma2R.js +0 -2
- package/dist/action-runtime-DfuYoMjG.js +0 -561
- package/dist/action-runtime.runtime-DQErZYpz.js +0 -2
- package/dist/actions-D3NuJvva.js +0 -876
- package/dist/actions.runtime-BIRU_G4M.js +0 -2
- package/dist/approval-handler.runtime-BA05P0QT.js +0 -367
- package/dist/block-text-DkHaoGem.js +0 -79
- package/dist/channel-B9fVdW3s.js +0 -1118
- package/dist/channel-type-DXyos1d2.js +0 -108
- package/dist/channel.setup-CLP5oTvh.js +0 -56
- package/dist/config-adapter-CxBQH8fq.js +0 -566
- package/dist/config-schema-SgZT6nXV.js +0 -373
- package/dist/cursor-pages-eX7p8Wwt.js +0 -19
- package/dist/directory-config-CnCIAktf.js +0 -54
- package/dist/directory-live-DKunWh3A.js +0 -131
- package/dist/doctor-contract-CsGH1Dfc.js +0 -158
- package/dist/group-policy-NQZti9t-.js +0 -2442
- package/dist/message-tool-api-DkhFpMoy.js +0 -127
- package/dist/monitor-CmKz0wtI.js +0 -13
- package/dist/outbound-adapter-BkuMp2Vs.js +0 -236
- package/dist/pipeline.runtime-DgtmuYCP.js +0 -4360
- package/dist/plugin-routes-CLp4obpN.js +0 -22
- package/dist/policy-PRysPn23.js +0 -65
- package/dist/preflight-audio.runtime-D5Bgags0.js +0 -3
- package/dist/probe-CgDsSops.js +0 -345
- package/dist/provider-DmRizMZt.js +0 -5900
- package/dist/relay-source-Blxj8xb4.js +0 -272
- package/dist/replies-4s_Vq_z9.js +0 -457
- package/dist/resolve-channels-yEqmM-3I.js +0 -92
- package/dist/resolve-users-BOrt5K-5.js +0 -118
- package/dist/rolldown-runtime-8H4AJuhK.js +0 -14
- package/dist/runtime-JSVZSWAj.js +0 -8
- package/dist/runtime-api-QMb-Q5Ko.js +0 -10
- package/dist/scopes-BJSrkAp6.js +0 -73
- package/dist/secret-contract-DxmvbxBF.js +0 -87
- package/dist/security-audit-DR097212.js +0 -41
- package/dist/send-DsLeZpST.js +0 -1269
- package/dist/send.runtime-gUdK6V3h.js +0 -2
- package/dist/setup-surface-BeNzrMrJ.js +0 -148
- package/dist/shared-DgIN3Dcr.js +0 -268
- package/dist/slash-dispatch.runtime-zPkyl7dB.js +0 -33
- package/dist/streaming-compat-3_X-21wW.js +0 -44
- package/dist/target-parsing-N6lHogYZ.js +0 -73
- package/dist/targets-KmjP2E8s.js +0 -13
- package/node_modules/@slack/socket-mode/README.md +0 -221
- package/node_modules/@slack/socket-mode/dist/package.json +0 -75
- package/node_modules/@slack/socket-mode/dist/src/SlackWebSocket.d.ts +0 -102
- package/node_modules/@slack/socket-mode/dist/src/SlackWebSocket.d.ts.map +0 -1
- package/node_modules/@slack/socket-mode/dist/src/SlackWebSocket.js +0 -330
- package/node_modules/@slack/socket-mode/dist/src/SlackWebSocket.js.map +0 -1
- package/node_modules/@slack/socket-mode/dist/src/SocketModeClient.d.ts +0 -104
- package/node_modules/@slack/socket-mode/dist/src/SocketModeClient.d.ts.map +0 -1
- package/node_modules/@slack/socket-mode/dist/src/SocketModeClient.js +0 -412
- package/node_modules/@slack/socket-mode/dist/src/SocketModeClient.js.map +0 -1
- package/node_modules/@slack/socket-mode/dist/src/SocketModeOptions.d.ts +0 -77
- package/node_modules/@slack/socket-mode/dist/src/SocketModeOptions.d.ts.map +0 -1
- package/node_modules/@slack/socket-mode/dist/src/errors.d.ts +0 -54
- package/node_modules/@slack/socket-mode/dist/src/errors.d.ts.map +0 -1
- package/node_modules/@slack/socket-mode/dist/src/errors.js +0 -64
- package/node_modules/@slack/socket-mode/dist/src/errors.js.map +0 -1
- package/node_modules/@slack/socket-mode/dist/src/index.d.ts +0 -6
- package/node_modules/@slack/socket-mode/dist/src/index.d.ts.map +0 -1
- package/node_modules/@slack/socket-mode/dist/src/index.js +0 -19
- package/node_modules/@slack/socket-mode/dist/src/index.js.map +0 -1
- package/node_modules/@slack/socket-mode/node_modules/@slack/logger/LICENSE +0 -23
- package/node_modules/@slack/socket-mode/node_modules/@slack/logger/README.md +0 -66
- package/node_modules/@slack/socket-mode/node_modules/@slack/logger/dist/index.d.ts +0 -94
- package/node_modules/@slack/socket-mode/node_modules/@slack/logger/dist/index.d.ts.map +0 -1
- package/node_modules/@slack/socket-mode/node_modules/@slack/logger/dist/index.js +0 -98
- package/node_modules/@slack/socket-mode/node_modules/@slack/logger/dist/index.js.map +0 -1
- package/node_modules/@slack/socket-mode/node_modules/@slack/logger/package.json +0 -42
- package/node_modules/@slack/socket-mode/node_modules/@types/node/README.md +0 -15
- package/node_modules/@slack/socket-mode/node_modules/@types/node/assert/strict.d.ts +0 -68
- package/node_modules/@slack/socket-mode/node_modules/@types/node/assert.d.ts +0 -1077
- package/node_modules/@slack/socket-mode/node_modules/@types/node/async_hooks.d.ts +0 -711
- package/node_modules/@slack/socket-mode/node_modules/@types/node/buffer.buffer.d.ts +0 -466
- package/node_modules/@slack/socket-mode/node_modules/@types/node/buffer.d.ts +0 -1799
- package/node_modules/@slack/socket-mode/node_modules/@types/node/child_process.d.ts +0 -1362
- package/node_modules/@slack/socket-mode/node_modules/@types/node/cluster.d.ts +0 -432
- package/node_modules/@slack/socket-mode/node_modules/@types/node/console.d.ts +0 -93
- package/node_modules/@slack/socket-mode/node_modules/@types/node/constants.d.ts +0 -14
- package/node_modules/@slack/socket-mode/node_modules/@types/node/crypto.d.ts +0 -3954
- package/node_modules/@slack/socket-mode/node_modules/@types/node/dgram.d.ts +0 -537
- package/node_modules/@slack/socket-mode/node_modules/@types/node/diagnostics_channel.d.ts +0 -794
- package/node_modules/@slack/socket-mode/node_modules/@types/node/dns/promises.d.ts +0 -497
- package/node_modules/@slack/socket-mode/node_modules/@types/node/dns.d.ts +0 -876
- package/node_modules/@slack/socket-mode/node_modules/@types/node/domain.d.ts +0 -150
- package/node_modules/@slack/socket-mode/node_modules/@types/node/events.d.ts +0 -1008
- package/node_modules/@slack/socket-mode/node_modules/@types/node/ffi.d.ts +0 -486
- package/node_modules/@slack/socket-mode/node_modules/@types/node/fs/promises.d.ts +0 -1481
- package/node_modules/@slack/socket-mode/node_modules/@types/node/fs.d.ts +0 -4786
- package/node_modules/@slack/socket-mode/node_modules/@types/node/globals.d.ts +0 -150
- package/node_modules/@slack/socket-mode/node_modules/@types/node/globals.typedarray.d.ts +0 -101
- package/node_modules/@slack/socket-mode/node_modules/@types/node/http.d.ts +0 -2172
- package/node_modules/@slack/socket-mode/node_modules/@types/node/http2.d.ts +0 -2489
- package/node_modules/@slack/socket-mode/node_modules/@types/node/https.d.ts +0 -400
- package/node_modules/@slack/socket-mode/node_modules/@types/node/index.d.ts +0 -115
- package/node_modules/@slack/socket-mode/node_modules/@types/node/inspector/promises.d.ts +0 -35
- package/node_modules/@slack/socket-mode/node_modules/@types/node/inspector.d.ts +0 -264
- package/node_modules/@slack/socket-mode/node_modules/@types/node/inspector.generated.d.ts +0 -4406
- package/node_modules/@slack/socket-mode/node_modules/@types/node/module.d.ts +0 -726
- package/node_modules/@slack/socket-mode/node_modules/@types/node/net.d.ts +0 -970
- package/node_modules/@slack/socket-mode/node_modules/@types/node/os.d.ts +0 -498
- package/node_modules/@slack/socket-mode/node_modules/@types/node/package.json +0 -155
- package/node_modules/@slack/socket-mode/node_modules/@types/node/path/posix.d.ts +0 -8
- package/node_modules/@slack/socket-mode/node_modules/@types/node/path/win32.d.ts +0 -8
- package/node_modules/@slack/socket-mode/node_modules/@types/node/path.d.ts +0 -178
- package/node_modules/@slack/socket-mode/node_modules/@types/node/perf_hooks.d.ts +0 -604
- package/node_modules/@slack/socket-mode/node_modules/@types/node/process.d.ts +0 -2217
- package/node_modules/@slack/socket-mode/node_modules/@types/node/punycode.d.ts +0 -89
- package/node_modules/@slack/socket-mode/node_modules/@types/node/querystring.d.ts +0 -139
- package/node_modules/@slack/socket-mode/node_modules/@types/node/quic.d.ts +0 -978
- package/node_modules/@slack/socket-mode/node_modules/@types/node/readline/promises.d.ts +0 -158
- package/node_modules/@slack/socket-mode/node_modules/@types/node/readline.d.ts +0 -508
- package/node_modules/@slack/socket-mode/node_modules/@types/node/repl.d.ts +0 -420
- package/node_modules/@slack/socket-mode/node_modules/@types/node/sea.d.ts +0 -47
- package/node_modules/@slack/socket-mode/node_modules/@types/node/sqlite.d.ts +0 -1123
- package/node_modules/@slack/socket-mode/node_modules/@types/node/stream/consumers.d.ts +0 -114
- package/node_modules/@slack/socket-mode/node_modules/@types/node/stream/iter.d.ts +0 -451
- package/node_modules/@slack/socket-mode/node_modules/@types/node/stream/promises.d.ts +0 -211
- package/node_modules/@slack/socket-mode/node_modules/@types/node/stream/web.d.ts +0 -300
- package/node_modules/@slack/socket-mode/node_modules/@types/node/stream.d.ts +0 -1806
- package/node_modules/@slack/socket-mode/node_modules/@types/node/string_decoder.d.ts +0 -27
- package/node_modules/@slack/socket-mode/node_modules/@types/node/test/reporters.d.ts +0 -59
- package/node_modules/@slack/socket-mode/node_modules/@types/node/test.d.ts +0 -2389
- package/node_modules/@slack/socket-mode/node_modules/@types/node/timers/promises.d.ts +0 -93
- package/node_modules/@slack/socket-mode/node_modules/@types/node/timers.d.ts +0 -149
- package/node_modules/@slack/socket-mode/node_modules/@types/node/tls.d.ts +0 -1193
- package/node_modules/@slack/socket-mode/node_modules/@types/node/trace_events.d.ts +0 -103
- package/node_modules/@slack/socket-mode/node_modules/@types/node/ts5.6/buffer.buffer.d.ts +0 -462
- package/node_modules/@slack/socket-mode/node_modules/@types/node/ts5.6/compatibility/float16array.d.ts +0 -71
- package/node_modules/@slack/socket-mode/node_modules/@types/node/ts5.6/globals.typedarray.d.ts +0 -36
- package/node_modules/@slack/socket-mode/node_modules/@types/node/ts5.6/index.d.ts +0 -117
- package/node_modules/@slack/socket-mode/node_modules/@types/node/ts5.7/compatibility/float16array.d.ts +0 -72
- package/node_modules/@slack/socket-mode/node_modules/@types/node/ts5.7/index.d.ts +0 -117
- package/node_modules/@slack/socket-mode/node_modules/@types/node/tty.d.ts +0 -225
- package/node_modules/@slack/socket-mode/node_modules/@types/node/url.d.ts +0 -556
- package/node_modules/@slack/socket-mode/node_modules/@types/node/util/types.d.ts +0 -558
- package/node_modules/@slack/socket-mode/node_modules/@types/node/util.d.ts +0 -1677
- package/node_modules/@slack/socket-mode/node_modules/@types/node/v8.d.ts +0 -1062
- package/node_modules/@slack/socket-mode/node_modules/@types/node/vm.d.ts +0 -1136
- package/node_modules/@slack/socket-mode/node_modules/@types/node/wasi.d.ts +0 -131
- package/node_modules/@slack/socket-mode/node_modules/@types/node/web-globals/abortcontroller.d.ts +0 -59
- package/node_modules/@slack/socket-mode/node_modules/@types/node/web-globals/blob.d.ts +0 -23
- package/node_modules/@slack/socket-mode/node_modules/@types/node/web-globals/console.d.ts +0 -9
- package/node_modules/@slack/socket-mode/node_modules/@types/node/web-globals/crypto.d.ts +0 -39
- package/node_modules/@slack/socket-mode/node_modules/@types/node/web-globals/domexception.d.ts +0 -83
- package/node_modules/@slack/socket-mode/node_modules/@types/node/web-globals/encoding.d.ts +0 -11
- package/node_modules/@slack/socket-mode/node_modules/@types/node/web-globals/events.d.ts +0 -106
- package/node_modules/@slack/socket-mode/node_modules/@types/node/web-globals/fetch.d.ts +0 -69
- package/node_modules/@slack/socket-mode/node_modules/@types/node/web-globals/importmeta.d.ts +0 -13
- package/node_modules/@slack/socket-mode/node_modules/@types/node/web-globals/messaging.d.ts +0 -23
- package/node_modules/@slack/socket-mode/node_modules/@types/node/web-globals/navigator.d.ts +0 -25
- package/node_modules/@slack/socket-mode/node_modules/@types/node/web-globals/performance.d.ts +0 -45
- package/node_modules/@slack/socket-mode/node_modules/@types/node/web-globals/storage.d.ts +0 -24
- package/node_modules/@slack/socket-mode/node_modules/@types/node/web-globals/streams.d.ts +0 -115
- package/node_modules/@slack/socket-mode/node_modules/@types/node/web-globals/timers.d.ts +0 -44
- package/node_modules/@slack/socket-mode/node_modules/@types/node/web-globals/url.d.ts +0 -24
- package/node_modules/@slack/socket-mode/node_modules/@types/node/worker_threads.d.ts +0 -669
- package/node_modules/@slack/socket-mode/node_modules/@types/node/zlib/iter.d.ts +0 -131
- package/node_modules/@slack/socket-mode/node_modules/@types/node/zlib.d.ts +0 -589
- package/node_modules/@slack/socket-mode/node_modules/undici-types/LICENSE +0 -21
- package/node_modules/@slack/socket-mode/node_modules/undici-types/README.md +0 -6
- package/node_modules/@slack/socket-mode/node_modules/undici-types/agent.d.ts +0 -30
- package/node_modules/@slack/socket-mode/node_modules/undici-types/api.d.ts +0 -43
- package/node_modules/@slack/socket-mode/node_modules/undici-types/balanced-pool.d.ts +0 -30
- package/node_modules/@slack/socket-mode/node_modules/undici-types/cache-interceptor.d.ts +0 -179
- package/node_modules/@slack/socket-mode/node_modules/undici-types/cache.d.ts +0 -36
- package/node_modules/@slack/socket-mode/node_modules/undici-types/client-stats.d.ts +0 -15
- package/node_modules/@slack/socket-mode/node_modules/undici-types/client.d.ts +0 -129
- package/node_modules/@slack/socket-mode/node_modules/undici-types/connector.d.ts +0 -36
- package/node_modules/@slack/socket-mode/node_modules/undici-types/content-type.d.ts +0 -21
- package/node_modules/@slack/socket-mode/node_modules/undici-types/cookies.d.ts +0 -30
- package/node_modules/@slack/socket-mode/node_modules/undici-types/diagnostics-channel.d.ts +0 -74
- package/node_modules/@slack/socket-mode/node_modules/undici-types/dispatcher.d.ts +0 -253
- package/node_modules/@slack/socket-mode/node_modules/undici-types/dispatcher1-wrapper.d.ts +0 -7
- package/node_modules/@slack/socket-mode/node_modules/undici-types/env-http-proxy-agent.d.ts +0 -22
- package/node_modules/@slack/socket-mode/node_modules/undici-types/errors.d.ts +0 -177
- package/node_modules/@slack/socket-mode/node_modules/undici-types/eventsource.d.ts +0 -66
- package/node_modules/@slack/socket-mode/node_modules/undici-types/fetch.d.ts +0 -231
- package/node_modules/@slack/socket-mode/node_modules/undici-types/formdata.d.ts +0 -108
- package/node_modules/@slack/socket-mode/node_modules/undici-types/global-dispatcher.d.ts +0 -9
- package/node_modules/@slack/socket-mode/node_modules/undici-types/global-origin.d.ts +0 -7
- package/node_modules/@slack/socket-mode/node_modules/undici-types/h2c-client.d.ts +0 -73
- package/node_modules/@slack/socket-mode/node_modules/undici-types/handlers.d.ts +0 -14
- package/node_modules/@slack/socket-mode/node_modules/undici-types/header.d.ts +0 -165
- package/node_modules/@slack/socket-mode/node_modules/undici-types/index.d.ts +0 -93
- package/node_modules/@slack/socket-mode/node_modules/undici-types/interceptors.d.ts +0 -80
- package/node_modules/@slack/socket-mode/node_modules/undici-types/mock-agent.d.ts +0 -68
- package/node_modules/@slack/socket-mode/node_modules/undici-types/mock-call-history.d.ts +0 -111
- package/node_modules/@slack/socket-mode/node_modules/undici-types/mock-client.d.ts +0 -27
- package/node_modules/@slack/socket-mode/node_modules/undici-types/mock-errors.d.ts +0 -12
- package/node_modules/@slack/socket-mode/node_modules/undici-types/mock-interceptor.d.ts +0 -94
- package/node_modules/@slack/socket-mode/node_modules/undici-types/mock-pool.d.ts +0 -27
- package/node_modules/@slack/socket-mode/node_modules/undici-types/package.json +0 -55
- package/node_modules/@slack/socket-mode/node_modules/undici-types/patch.d.ts +0 -29
- package/node_modules/@slack/socket-mode/node_modules/undici-types/pool-stats.d.ts +0 -19
- package/node_modules/@slack/socket-mode/node_modules/undici-types/pool.d.ts +0 -39
- package/node_modules/@slack/socket-mode/node_modules/undici-types/proxy-agent.d.ts +0 -29
- package/node_modules/@slack/socket-mode/node_modules/undici-types/readable.d.ts +0 -68
- package/node_modules/@slack/socket-mode/node_modules/undici-types/retry-agent.d.ts +0 -8
- package/node_modules/@slack/socket-mode/node_modules/undici-types/retry-handler.d.ts +0 -125
- package/node_modules/@slack/socket-mode/node_modules/undici-types/round-robin-pool.d.ts +0 -39
- package/node_modules/@slack/socket-mode/node_modules/undici-types/snapshot-agent.d.ts +0 -113
- package/node_modules/@slack/socket-mode/node_modules/undici-types/socks5-proxy-agent.d.ts +0 -25
- package/node_modules/@slack/socket-mode/node_modules/undici-types/util.d.ts +0 -18
- package/node_modules/@slack/socket-mode/node_modules/undici-types/utility.d.ts +0 -7
- package/node_modules/@slack/socket-mode/node_modules/undici-types/webidl.d.ts +0 -346
- package/node_modules/@slack/socket-mode/node_modules/undici-types/websocket.d.ts +0 -188
- package/node_modules/@slack/socket-mode/package.json +0 -75
- package/node_modules/get-east-asian-width/index.d.ts +0 -60
- package/node_modules/get-east-asian-width/index.js +0 -30
- package/node_modules/get-east-asian-width/lookup-data.js +0 -21
- package/node_modules/get-east-asian-width/lookup.js +0 -138
- package/node_modules/get-east-asian-width/package.json +0 -71
- package/node_modules/get-east-asian-width/readme.md +0 -65
- package/node_modules/get-east-asian-width/utilities.js +0 -24
- package/node_modules/p-map/index.d.ts +0 -155
- package/node_modules/p-map/index.js +0 -285
- package/node_modules/p-map/license +0 -9
- package/node_modules/p-map/package.json +0 -57
- package/node_modules/p-map/readme.md +0 -190
- package/node_modules/undici/LICENSE +0 -21
- package/node_modules/undici/README.md +0 -741
- package/node_modules/undici/docs/docs/api/Agent.md +0 -84
- package/node_modules/undici/docs/docs/api/BalancedPool.md +0 -99
- package/node_modules/undici/docs/docs/api/CacheStorage.md +0 -30
- package/node_modules/undici/docs/docs/api/CacheStore.md +0 -164
- package/node_modules/undici/docs/docs/api/Client.md +0 -288
- package/node_modules/undici/docs/docs/api/ClientStats.md +0 -27
- package/node_modules/undici/docs/docs/api/Connector.md +0 -115
- package/node_modules/undici/docs/docs/api/ContentType.md +0 -57
- package/node_modules/undici/docs/docs/api/Cookies.md +0 -128
- package/node_modules/undici/docs/docs/api/Debug.md +0 -62
- package/node_modules/undici/docs/docs/api/DiagnosticsChannel.md +0 -315
- package/node_modules/undici/docs/docs/api/Dispatcher.md +0 -1392
- package/node_modules/undici/docs/docs/api/EnvHttpProxyAgent.md +0 -159
- package/node_modules/undici/docs/docs/api/Errors.md +0 -49
- package/node_modules/undici/docs/docs/api/EventSource.md +0 -45
- package/node_modules/undici/docs/docs/api/Fetch.md +0 -60
- package/node_modules/undici/docs/docs/api/GlobalInstallation.md +0 -139
- package/node_modules/undici/docs/docs/api/H2CClient.md +0 -263
- package/node_modules/undici/docs/docs/api/MockAgent.md +0 -603
- package/node_modules/undici/docs/docs/api/MockCallHistory.md +0 -197
- package/node_modules/undici/docs/docs/api/MockCallHistoryLog.md +0 -43
- package/node_modules/undici/docs/docs/api/MockClient.md +0 -81
- package/node_modules/undici/docs/docs/api/MockErrors.md +0 -12
- package/node_modules/undici/docs/docs/api/MockPool.md +0 -555
- package/node_modules/undici/docs/docs/api/Pool.md +0 -84
- package/node_modules/undici/docs/docs/api/PoolStats.md +0 -35
- package/node_modules/undici/docs/docs/api/ProxyAgent.md +0 -229
- package/node_modules/undici/docs/docs/api/RedirectHandler.md +0 -93
- package/node_modules/undici/docs/docs/api/RetryAgent.md +0 -50
- package/node_modules/undici/docs/docs/api/RetryHandler.md +0 -118
- package/node_modules/undici/docs/docs/api/RoundRobinPool.md +0 -145
- package/node_modules/undici/docs/docs/api/SnapshotAgent.md +0 -616
- package/node_modules/undici/docs/docs/api/Socks5ProxyAgent.md +0 -275
- package/node_modules/undici/docs/docs/api/Util.md +0 -25
- package/node_modules/undici/docs/docs/api/WebSocket.md +0 -141
- package/node_modules/undici/docs/docs/api/api-lifecycle.md +0 -91
- package/node_modules/undici/docs/docs/best-practices/client-certificate.md +0 -64
- package/node_modules/undici/docs/docs/best-practices/crawling.md +0 -58
- package/node_modules/undici/docs/docs/best-practices/mocking-request.md +0 -190
- package/node_modules/undici/docs/docs/best-practices/proxy.md +0 -127
- package/node_modules/undici/docs/docs/best-practices/undici-vs-builtin-fetch.md +0 -224
- package/node_modules/undici/docs/docs/best-practices/writing-tests.md +0 -63
- package/node_modules/undici/index-fetch.js +0 -65
- package/node_modules/undici/index.d.ts +0 -3
- package/node_modules/undici/index.js +0 -234
- package/node_modules/undici/lib/api/abort-signal.js +0 -59
- package/node_modules/undici/lib/api/api-connect.js +0 -110
- package/node_modules/undici/lib/api/api-pipeline.js +0 -252
- package/node_modules/undici/lib/api/api-request.js +0 -214
- package/node_modules/undici/lib/api/api-stream.js +0 -209
- package/node_modules/undici/lib/api/api-upgrade.js +0 -111
- package/node_modules/undici/lib/api/index.js +0 -7
- package/node_modules/undici/lib/api/readable.js +0 -580
- package/node_modules/undici/lib/cache/memory-cache-store.js +0 -234
- package/node_modules/undici/lib/cache/sqlite-cache-store.js +0 -461
- package/node_modules/undici/lib/core/connect.js +0 -153
- package/node_modules/undici/lib/core/constants.js +0 -143
- package/node_modules/undici/lib/core/diagnostics.js +0 -227
- package/node_modules/undici/lib/core/errors.js +0 -477
- package/node_modules/undici/lib/core/request.js +0 -453
- package/node_modules/undici/lib/core/socks5-client.js +0 -422
- package/node_modules/undici/lib/core/socks5-utils.js +0 -212
- package/node_modules/undici/lib/core/symbols.js +0 -75
- package/node_modules/undici/lib/core/tree.js +0 -160
- package/node_modules/undici/lib/core/util.js +0 -992
- package/node_modules/undici/lib/dispatcher/agent.js +0 -158
- package/node_modules/undici/lib/dispatcher/balanced-pool.js +0 -219
- package/node_modules/undici/lib/dispatcher/client-h1.js +0 -1722
- package/node_modules/undici/lib/dispatcher/client-h2.js +0 -995
- package/node_modules/undici/lib/dispatcher/client.js +0 -664
- package/node_modules/undici/lib/dispatcher/dispatcher-base.js +0 -184
- package/node_modules/undici/lib/dispatcher/dispatcher.js +0 -48
- package/node_modules/undici/lib/dispatcher/env-http-proxy-agent.js +0 -146
- package/node_modules/undici/lib/dispatcher/fixed-queue.js +0 -135
- package/node_modules/undici/lib/dispatcher/h2c-client.js +0 -51
- package/node_modules/undici/lib/dispatcher/pool-base.js +0 -214
- package/node_modules/undici/lib/dispatcher/pool.js +0 -118
- package/node_modules/undici/lib/dispatcher/proxy-agent.js +0 -319
- package/node_modules/undici/lib/dispatcher/retry-agent.js +0 -35
- package/node_modules/undici/lib/dispatcher/round-robin-pool.js +0 -137
- package/node_modules/undici/lib/dispatcher/socks5-proxy-agent.js +0 -260
- package/node_modules/undici/lib/encoding/index.js +0 -33
- package/node_modules/undici/lib/global.js +0 -59
- package/node_modules/undici/lib/handler/cache-handler.js +0 -578
- package/node_modules/undici/lib/handler/cache-revalidation-handler.js +0 -124
- package/node_modules/undici/lib/handler/decorator-handler.js +0 -67
- package/node_modules/undici/lib/handler/deduplication-handler.js +0 -460
- package/node_modules/undici/lib/handler/redirect-handler.js +0 -238
- package/node_modules/undici/lib/handler/retry-handler.js +0 -394
- package/node_modules/undici/lib/handler/unwrap-handler.js +0 -106
- package/node_modules/undici/lib/handler/wrap-handler.js +0 -105
- package/node_modules/undici/lib/interceptor/cache.js +0 -495
- package/node_modules/undici/lib/interceptor/decompress.js +0 -259
- package/node_modules/undici/lib/interceptor/deduplicate.js +0 -117
- package/node_modules/undici/lib/interceptor/dns.js +0 -571
- package/node_modules/undici/lib/interceptor/dump.js +0 -112
- package/node_modules/undici/lib/interceptor/redirect.js +0 -21
- package/node_modules/undici/lib/interceptor/response-error.js +0 -95
- package/node_modules/undici/lib/interceptor/retry.js +0 -19
- package/node_modules/undici/lib/llhttp/.gitkeep +0 -0
- package/node_modules/undici/lib/llhttp/constants.d.ts +0 -195
- package/node_modules/undici/lib/llhttp/constants.js +0 -531
- package/node_modules/undici/lib/llhttp/llhttp-wasm.js +0 -15
- package/node_modules/undici/lib/llhttp/llhttp_simd-wasm.js +0 -15
- package/node_modules/undici/lib/llhttp/utils.d.ts +0 -2
- package/node_modules/undici/lib/llhttp/utils.js +0 -12
- package/node_modules/undici/lib/mock/mock-agent.js +0 -232
- package/node_modules/undici/lib/mock/mock-call-history.js +0 -248
- package/node_modules/undici/lib/mock/mock-client.js +0 -68
- package/node_modules/undici/lib/mock/mock-errors.js +0 -29
- package/node_modules/undici/lib/mock/mock-interceptor.js +0 -209
- package/node_modules/undici/lib/mock/mock-pool.js +0 -68
- package/node_modules/undici/lib/mock/mock-symbols.js +0 -32
- package/node_modules/undici/lib/mock/mock-utils.js +0 -486
- package/node_modules/undici/lib/mock/pending-interceptors-formatter.js +0 -43
- package/node_modules/undici/lib/mock/snapshot-agent.js +0 -353
- package/node_modules/undici/lib/mock/snapshot-recorder.js +0 -588
- package/node_modules/undici/lib/mock/snapshot-utils.js +0 -158
- package/node_modules/undici/lib/util/cache.js +0 -414
- package/node_modules/undici/lib/util/date.js +0 -653
- package/node_modules/undici/lib/util/promise.js +0 -28
- package/node_modules/undici/lib/util/runtime-features.js +0 -124
- package/node_modules/undici/lib/util/stats.js +0 -32
- package/node_modules/undici/lib/util/timers.js +0 -425
- package/node_modules/undici/lib/web/cache/cache.js +0 -864
- package/node_modules/undici/lib/web/cache/cachestorage.js +0 -152
- package/node_modules/undici/lib/web/cache/util.js +0 -45
- package/node_modules/undici/lib/web/cookies/constants.js +0 -12
- package/node_modules/undici/lib/web/cookies/index.js +0 -199
- package/node_modules/undici/lib/web/cookies/parse.js +0 -314
- package/node_modules/undici/lib/web/cookies/util.js +0 -282
- package/node_modules/undici/lib/web/eventsource/eventsource-stream.js +0 -399
- package/node_modules/undici/lib/web/eventsource/eventsource.js +0 -501
- package/node_modules/undici/lib/web/eventsource/util.js +0 -29
- package/node_modules/undici/lib/web/fetch/LICENSE +0 -21
- package/node_modules/undici/lib/web/fetch/body.js +0 -509
- package/node_modules/undici/lib/web/fetch/constants.js +0 -131
- package/node_modules/undici/lib/web/fetch/data-url.js +0 -596
- package/node_modules/undici/lib/web/fetch/formdata-parser.js +0 -586
- package/node_modules/undici/lib/web/fetch/formdata.js +0 -259
- package/node_modules/undici/lib/web/fetch/global.js +0 -40
- package/node_modules/undici/lib/web/fetch/headers.js +0 -719
- package/node_modules/undici/lib/web/fetch/index.js +0 -2413
- package/node_modules/undici/lib/web/fetch/request.js +0 -1115
- package/node_modules/undici/lib/web/fetch/response.js +0 -641
- package/node_modules/undici/lib/web/fetch/util.js +0 -1522
- package/node_modules/undici/lib/web/infra/index.js +0 -229
- package/node_modules/undici/lib/web/subresource-integrity/Readme.md +0 -9
- package/node_modules/undici/lib/web/subresource-integrity/subresource-integrity.js +0 -307
- package/node_modules/undici/lib/web/webidl/index.js +0 -1006
- package/node_modules/undici/lib/web/websocket/connection.js +0 -329
- package/node_modules/undici/lib/web/websocket/constants.js +0 -126
- package/node_modules/undici/lib/web/websocket/events.js +0 -331
- package/node_modules/undici/lib/web/websocket/frame.js +0 -133
- package/node_modules/undici/lib/web/websocket/permessage-deflate.js +0 -100
- package/node_modules/undici/lib/web/websocket/receiver.js +0 -507
- package/node_modules/undici/lib/web/websocket/sender.js +0 -109
- package/node_modules/undici/lib/web/websocket/stream/websocketerror.js +0 -104
- package/node_modules/undici/lib/web/websocket/stream/websocketstream.js +0 -498
- package/node_modules/undici/lib/web/websocket/util.js +0 -347
- package/node_modules/undici/lib/web/websocket/websocket.js +0 -758
- package/node_modules/undici/package.json +0 -152
- package/node_modules/undici/scripts/strip-comments.js +0 -10
- package/node_modules/undici/types/README.md +0 -6
- package/node_modules/undici/types/agent.d.ts +0 -32
- package/node_modules/undici/types/api.d.ts +0 -43
- package/node_modules/undici/types/balanced-pool.d.ts +0 -30
- package/node_modules/undici/types/cache-interceptor.d.ts +0 -179
- package/node_modules/undici/types/cache.d.ts +0 -36
- package/node_modules/undici/types/client-stats.d.ts +0 -15
- package/node_modules/undici/types/client.d.ts +0 -139
- package/node_modules/undici/types/connector.d.ts +0 -36
- package/node_modules/undici/types/content-type.d.ts +0 -21
- package/node_modules/undici/types/cookies.d.ts +0 -30
- package/node_modules/undici/types/diagnostics-channel.d.ts +0 -74
- package/node_modules/undici/types/dispatcher.d.ts +0 -275
- package/node_modules/undici/types/env-http-proxy-agent.d.ts +0 -22
- package/node_modules/undici/types/errors.d.ts +0 -177
- package/node_modules/undici/types/eventsource.d.ts +0 -66
- package/node_modules/undici/types/fetch.d.ts +0 -231
- package/node_modules/undici/types/formdata.d.ts +0 -114
- package/node_modules/undici/types/global-dispatcher.d.ts +0 -9
- package/node_modules/undici/types/global-origin.d.ts +0 -7
- package/node_modules/undici/types/h2c-client.d.ts +0 -73
- package/node_modules/undici/types/handlers.d.ts +0 -14
- package/node_modules/undici/types/header.d.ts +0 -160
- package/node_modules/undici/types/index.d.ts +0 -91
- package/node_modules/undici/types/interceptors.d.ts +0 -80
- package/node_modules/undici/types/mock-agent.d.ts +0 -68
- package/node_modules/undici/types/mock-call-history.d.ts +0 -111
- package/node_modules/undici/types/mock-client.d.ts +0 -27
- package/node_modules/undici/types/mock-errors.d.ts +0 -12
- package/node_modules/undici/types/mock-interceptor.d.ts +0 -94
- package/node_modules/undici/types/mock-pool.d.ts +0 -27
- package/node_modules/undici/types/patch.d.ts +0 -29
- package/node_modules/undici/types/pool-stats.d.ts +0 -19
- package/node_modules/undici/types/pool.d.ts +0 -41
- package/node_modules/undici/types/proxy-agent.d.ts +0 -29
- package/node_modules/undici/types/readable.d.ts +0 -68
- package/node_modules/undici/types/retry-agent.d.ts +0 -8
- package/node_modules/undici/types/retry-handler.d.ts +0 -125
- package/node_modules/undici/types/round-robin-pool.d.ts +0 -41
- package/node_modules/undici/types/snapshot-agent.d.ts +0 -109
- package/node_modules/undici/types/socks5-proxy-agent.d.ts +0 -25
- package/node_modules/undici/types/util.d.ts +0 -18
- package/node_modules/undici/types/utility.d.ts +0 -7
- package/node_modules/undici/types/webidl.d.ts +0 -347
- package/node_modules/undici/types/websocket.d.ts +0 -188
- /package/dist/{registry-bbjH7IHX.js → .setup/registry-bbjH7IHX.mjs} +0 -0
- /package/dist/{slash-commands.runtime-BTTMlmwy.js → .setup/slash-commands.runtime-BTTMlmwy.mjs} +0 -0
- /package/dist/{slash-plugin-commands.runtime-Dosfcx3X.js → .setup/slash-plugin-commands.runtime-Dosfcx3X.mjs} +0 -0
- /package/dist/{slash-skill-commands.runtime-CD1J2ODY.js → .setup/slash-skill-commands.runtime-CD1J2ODY.mjs} +0 -0
- /package/dist/{thread-ts-DUGhaYKq.js → .setup/thread-ts-DUGhaYKq.mjs} +0 -0
- /package/node_modules/@slack/{socket-mode → bolt/node_modules/@slack/socket-mode}/LICENSE +0 -0
- /package/node_modules/@slack/{socket-mode → bolt/node_modules/@slack/socket-mode}/dist/src/SocketModeOptions.js +0 -0
- /package/node_modules/@slack/{socket-mode → bolt/node_modules/@slack/socket-mode}/dist/src/SocketModeOptions.js.map +0 -0
- /package/node_modules/@slack/{socket-mode → bolt/node_modules/@slack/socket-mode}/dist/src/UnrecoverableSocketModeStartError.d.ts +0 -0
- /package/node_modules/@slack/{socket-mode → bolt/node_modules/@slack/socket-mode}/dist/src/UnrecoverableSocketModeStartError.d.ts.map +0 -0
- /package/node_modules/@slack/{socket-mode → bolt/node_modules/@slack/socket-mode}/dist/src/UnrecoverableSocketModeStartError.js +0 -0
- /package/node_modules/@slack/{socket-mode → bolt/node_modules/@slack/socket-mode}/dist/src/UnrecoverableSocketModeStartError.js.map +0 -0
- /package/node_modules/@slack/{socket-mode → bolt/node_modules/@slack/socket-mode}/dist/src/logger.d.ts +0 -0
- /package/node_modules/@slack/{socket-mode → bolt/node_modules/@slack/socket-mode}/dist/src/logger.d.ts.map +0 -0
- /package/node_modules/@slack/{socket-mode → bolt/node_modules/@slack/socket-mode}/dist/src/logger.js +0 -0
- /package/node_modules/@slack/{socket-mode → bolt/node_modules/@slack/socket-mode}/dist/src/logger.js.map +0 -0
- /package/node_modules/@slack/{socket-mode/node_modules/@types/node → bolt/node_modules/@types/ws}/LICENSE +0 -0
- /package/node_modules/@slack/{socket-mode → bolt}/node_modules/eventemitter3/LICENSE +0 -0
- /package/node_modules/@slack/{socket-mode → bolt}/node_modules/eventemitter3/README.md +0 -0
- /package/node_modules/@slack/{socket-mode → bolt}/node_modules/eventemitter3/dist/eventemitter3.esm.js +0 -0
- /package/node_modules/@slack/{socket-mode → bolt}/node_modules/eventemitter3/dist/eventemitter3.esm.min.js +0 -0
- /package/node_modules/@slack/{socket-mode → bolt}/node_modules/eventemitter3/dist/eventemitter3.esm.min.js.map +0 -0
- /package/node_modules/@slack/{socket-mode → bolt}/node_modules/eventemitter3/dist/eventemitter3.umd.js +0 -0
- /package/node_modules/@slack/{socket-mode → bolt}/node_modules/eventemitter3/dist/eventemitter3.umd.min.js +0 -0
- /package/node_modules/@slack/{socket-mode → bolt}/node_modules/eventemitter3/dist/eventemitter3.umd.min.js.map +0 -0
- /package/node_modules/@slack/{socket-mode → bolt}/node_modules/eventemitter3/index.d.ts +0 -0
- /package/node_modules/@slack/{socket-mode → bolt}/node_modules/eventemitter3/index.js +0 -0
- /package/node_modules/@slack/{socket-mode → bolt}/node_modules/eventemitter3/index.mjs +0 -0
- /package/node_modules/@slack/{socket-mode → bolt}/node_modules/eventemitter3/package.json +0 -0
- /package/node_modules/{get-east-asian-width → @slack/web-api/node_modules/is-stream}/license +0 -0
|
@@ -1,4360 +0,0 @@
|
|
|
1
|
-
import { t as resolveSlackReplyToMode } from "./account-reply-mode-DrUXogvO.js";
|
|
2
|
-
import { i as parseSlackTarget } from "./target-parsing-N6lHogYZ.js";
|
|
3
|
-
import "./targets-KmjP2E8s.js";
|
|
4
|
-
import { $ as escapeSlackMrkdwn, A as normalizeSlackOutboundText, C as hasSlackNativeDataBlock, F as SLACK_EDIT_TEXT_MAX_BYTES, H as truncateSlackText, L as SLACK_TEXT_LIMIT, U as truncateSlackTextByUtf8Bytes, _ as resolveSlackReplyRenderPlan, c as normalizeSlackAllowOwnerEntry, j as buildSlackBlocksFallbackText, s as normalizeAllowListLower, u as resolveSlackAllowListMatch } from "./group-policy-NQZti9t-.js";
|
|
5
|
-
import { r as formatSlackError } from "./probe-CgDsSops.js";
|
|
6
|
-
import { n as resolveSlackNativeStreaming, r as resolveSlackStreamingMode, t as mapStreamingModeToSlackLegacyDraftStreamMode } from "./streaming-compat-3_X-21wW.js";
|
|
7
|
-
import { _ as resolveSlackThreadHistory, b as buildSlackEditTextPayload, f as removeSlackReaction, l as reactSlackMessage, r as editSlackMessage, t as deleteSlackMessage, v as resolveSlackThreadStarter, y as formatSlackFileReference } from "./actions-D3NuJvva.js";
|
|
8
|
-
import { a as resolveSlackMessageText } from "./block-text-DkHaoGem.js";
|
|
9
|
-
import { c as hasSlackThreadParticipationWithPersistence, l as recordSlackThreadParticipation, r as sendMessageSlack, u as buildSlackNativeDataDeliveryPlan } from "./send-DsLeZpST.js";
|
|
10
|
-
import { C as stripSlackMentionsForCommandDetection, _ as readSessionUpdatedAt, b as resolveStorePath, d as resolveSlackCommandIngress, f as resolveSlackEffectiveAllowFrom, g as resolveSlackChatType, h as normalizeSlackChannelType, l as resolveConversationLabel$1, m as parseSlackAssistantThreadMetadata, o as authorizeSlackDirectMessage, p as buildSlackAssistantThreadMetadata, r as resolveSlackRoomContextHints, u as authorizeSlackBotRoomMessage, v as resolveChannelContextVisibilityMode, x as updateLastRoute, y as resolveChannelResetConfig } from "./provider-DmRizMZt.js";
|
|
11
|
-
import { n as resolveSlackChannelConfig } from "./policy-PRysPn23.js";
|
|
12
|
-
import { a as resolveDeliveredSlackReplyThreadTs, i as readSlackReplyBlocks, n as deliverReplies, o as resolveSlackThreadTs, s as emitSlackMessageSentHooks, t as createSlackReplyDeliveryPlan } from "./replies-4s_Vq_z9.js";
|
|
13
|
-
import { asOptionalRecord, normalizeLowercaseStringOrEmpty, normalizeOptionalLowercaseString, normalizeOptionalString } from "openclaw/plugin-sdk/string-coerce-runtime";
|
|
14
|
-
import { resolveAgentRoute, resolveInboundLastRouteSessionKey, resolveThreadSessionKeys } from "openclaw/plugin-sdk/routing";
|
|
15
|
-
import { buildChannelProgressDraftLine, buildChannelProgressDraftLineForEntry, createChannelMessageReplyPipeline, createChannelProgressDraftCompositor, createChannelProgressReceiptTracker, createDraftStreamLoop, defineFinalizableLivePreviewAdapter, deliverWithFinalizableLivePreviewAdapter, formatChannelProgressDraftText, formatPlanChecklistLines, isChannelProgressDraftWorkToolName, mergeChannelProgressDraftLine, resolveAgentOutboundIdentity, resolveChannelMessageSourceReplyDeliveryMode, resolveChannelProgressDraftConfig, resolveChannelProgressDraftMaxLineChars, resolveChannelProgressDraftMaxLines, resolveChannelProgressDraftRender, resolveChannelStreamingBlockEnabled, resolveChannelStreamingNativeTransport, resolveChannelStreamingPreviewToolProgress, resolveChannelStreamingSuppressDefaultToolProgressMessages } from "openclaw/plugin-sdk/channel-outbound";
|
|
16
|
-
import { createLazyRuntimeModule } from "openclaw/plugin-sdk/lazy-runtime";
|
|
17
|
-
import { danger, logVerbose, shouldLogVerbose } from "openclaw/plugin-sdk/runtime-env";
|
|
18
|
-
import { truncateUtf16Safe } from "openclaw/plugin-sdk/text-utility-runtime";
|
|
19
|
-
import { createHash } from "node:crypto";
|
|
20
|
-
import fs from "node:fs/promises";
|
|
21
|
-
import { formatErrorMessage, toErrorObject } from "openclaw/plugin-sdk/error-runtime";
|
|
22
|
-
import { asDateTimestampMs, asFiniteNumberInRange, parseStrictFiniteNumber, resolveExpiresAtMsFromDurationMs } from "openclaw/plugin-sdk/number-runtime";
|
|
23
|
-
import { buildTtsSupplementMediaPayload, getReplyPayloadTtsSupplement, resolveSendableOutboundReplyParts } from "openclaw/plugin-sdk/reply-payload";
|
|
24
|
-
import { filterSupplementalContextItems, resolvePinnedMainDmOwnerFromAllowlist, shouldIncludeSupplementalContext } from "openclaw/plugin-sdk/security-runtime";
|
|
25
|
-
import { ensureConfiguredBindingRouteReady, resolveConfiguredBindingRoute, resolveRuntimeConversationBindingRoute } from "openclaw/plugin-sdk/conversation-runtime";
|
|
26
|
-
import { createChannelHistoryWindow } from "openclaw/plugin-sdk/reply-history";
|
|
27
|
-
import { resolveDefaultAgentId, resolveHumanDelayConfig } from "openclaw/plugin-sdk/agent-runtime";
|
|
28
|
-
import { mergePairLoopGuardConfig } from "openclaw/plugin-sdk/pair-loop-guard-runtime";
|
|
29
|
-
import { enqueueSystemEvent } from "openclaw/plugin-sdk/system-event-runtime";
|
|
30
|
-
import { getGlobalHookRunner } from "openclaw/plugin-sdk/plugin-runtime";
|
|
31
|
-
import { resolveChannelImplicitMentions } from "openclaw/plugin-sdk/channel-ingress-runtime";
|
|
32
|
-
import { buildChannelInboundEventContext, buildMentionRegexes, classifyChannelInboundEvent, dispatchChannelInboundTurn, formatInboundEnvelope, hasVisibleInboundReplyDispatch, implicitMentionKindWhen, logInboundDrop, matchesMentionWithExplicit, recordDroppedChannelInboundHistory, resolveEnvelopeFormatOptions, resolveInboundMentionDecision, resolveInboundSupplementalSenderAllowed, resolveUnmentionedGroupInboundPolicy, toInboundMediaFactsWithMetadata } from "openclaw/plugin-sdk/channel-inbound";
|
|
33
|
-
import { DEFAULT_TIMING, createStatusReactionController, logAckFailure, logTypingFailure, resolveAckReaction, shouldAckReaction } from "openclaw/plugin-sdk/channel-feedback";
|
|
34
|
-
import { hasControlCommand } from "openclaw/plugin-sdk/command-detection";
|
|
35
|
-
import { isAbortRequestText } from "openclaw/plugin-sdk/command-primitives-runtime";
|
|
36
|
-
import { shouldHandleTextCommands } from "openclaw/plugin-sdk/command-surface";
|
|
37
|
-
import { mimeTypeFromFilePath } from "openclaw/plugin-sdk/media-mime";
|
|
38
|
-
import { runTasksWithConcurrency } from "openclaw/plugin-sdk/concurrency-runtime";
|
|
39
|
-
//#region extensions/slack/src/streaming.ts
|
|
40
|
-
/**
|
|
41
|
-
* Thrown when Slack definitively rejects a stream flush/finalize while text
|
|
42
|
-
* remains buffered locally by the Slack SDK. Carries the pending text so the
|
|
43
|
-
* caller can deliver it via the normal Slack reply path.
|
|
44
|
-
*/
|
|
45
|
-
var SlackStreamNotDeliveredError = class extends Error {
|
|
46
|
-
constructor(pendingText, slackCode) {
|
|
47
|
-
super(`slack-stream: finalize failed with ${slackCode} before buffered text reached Slack (${pendingText.length} chars pending)`);
|
|
48
|
-
this.name = "SlackStreamNotDeliveredError";
|
|
49
|
-
this.pendingText = pendingText;
|
|
50
|
-
this.slackCode = slackCode;
|
|
51
|
-
}
|
|
52
|
-
};
|
|
53
|
-
/**
|
|
54
|
-
* Start a new Slack text stream.
|
|
55
|
-
*
|
|
56
|
-
* Returns a {@link SlackStreamSession} that should be passed to
|
|
57
|
-
* {@link appendSlackStream} and {@link stopSlackStream}.
|
|
58
|
-
*
|
|
59
|
-
* The first chunk of text can optionally be included via `text`.
|
|
60
|
-
*/
|
|
61
|
-
async function startSlackStream(params) {
|
|
62
|
-
const { client, channel, threadTs, text, chunks, taskDisplayMode, teamId, userId, identity } = params;
|
|
63
|
-
const identityPayload = identity?.iconUrl ? {
|
|
64
|
-
...identity.username ? { username: identity.username } : {},
|
|
65
|
-
icon_url: identity.iconUrl
|
|
66
|
-
} : identity?.iconEmoji ? {
|
|
67
|
-
...identity.username ? { username: identity.username } : {},
|
|
68
|
-
icon_emoji: identity.iconEmoji
|
|
69
|
-
} : identity?.username ? { username: identity.username } : {};
|
|
70
|
-
logVerbose(`slack-stream: starting stream in ${channel} thread=${threadTs}${teamId ? ` team=${teamId}` : ""}${userId ? ` user=${userId}` : ""}`);
|
|
71
|
-
const streamer = client.chatStream({
|
|
72
|
-
channel,
|
|
73
|
-
thread_ts: threadTs,
|
|
74
|
-
...taskDisplayMode ? { task_display_mode: taskDisplayMode } : {},
|
|
75
|
-
...teamId ? { recipient_team_id: teamId } : {},
|
|
76
|
-
...userId ? { recipient_user_id: userId } : {},
|
|
77
|
-
...identityPayload
|
|
78
|
-
});
|
|
79
|
-
const session = {
|
|
80
|
-
streamer,
|
|
81
|
-
channel,
|
|
82
|
-
threadTs,
|
|
83
|
-
stopped: false,
|
|
84
|
-
delivered: false,
|
|
85
|
-
pendingText: ""
|
|
86
|
-
};
|
|
87
|
-
if (text || chunks?.length) {
|
|
88
|
-
if (text) session.pendingText += text;
|
|
89
|
-
try {
|
|
90
|
-
const result = await streamer.append({
|
|
91
|
-
...text ? { markdown_text: text } : {},
|
|
92
|
-
...chunks?.length ? { chunks } : {}
|
|
93
|
-
});
|
|
94
|
-
if (result) {
|
|
95
|
-
session.delivered = true;
|
|
96
|
-
session.pendingText = "";
|
|
97
|
-
}
|
|
98
|
-
logVerbose(`slack-stream: appended initial payload (${text?.length ?? 0} chars, ${chunks?.length ?? 0} chunks, ${result ? "flushed" : "buffered"})`);
|
|
99
|
-
} catch (err) {
|
|
100
|
-
if (isBenignSlackFinalizeError(err) && session.pendingText) throw new SlackStreamNotDeliveredError(session.pendingText, extractSlackErrorCode(err) ?? "unknown");
|
|
101
|
-
throw err;
|
|
102
|
-
}
|
|
103
|
-
}
|
|
104
|
-
return session;
|
|
105
|
-
}
|
|
106
|
-
/**
|
|
107
|
-
* Append markdown text to an active Slack stream.
|
|
108
|
-
*/
|
|
109
|
-
async function appendSlackStream(params) {
|
|
110
|
-
const { session, text, chunks } = params;
|
|
111
|
-
if (session.stopped) {
|
|
112
|
-
logVerbose("slack-stream: attempted to append to a stopped stream, ignoring");
|
|
113
|
-
return;
|
|
114
|
-
}
|
|
115
|
-
if (!text && !chunks?.length) return;
|
|
116
|
-
if (text) session.pendingText += text;
|
|
117
|
-
try {
|
|
118
|
-
const result = await session.streamer.append({
|
|
119
|
-
...text ? { markdown_text: text } : {},
|
|
120
|
-
...chunks?.length ? { chunks } : {}
|
|
121
|
-
});
|
|
122
|
-
if (result) {
|
|
123
|
-
session.delivered = true;
|
|
124
|
-
session.pendingText = "";
|
|
125
|
-
}
|
|
126
|
-
logVerbose(`slack-stream: appended ${text?.length ?? 0} chars, ${chunks?.length ?? 0} chunks (${result ? "flushed" : "buffered"})`);
|
|
127
|
-
} catch (err) {
|
|
128
|
-
if (isBenignSlackFinalizeError(err) && session.pendingText) throw new SlackStreamNotDeliveredError(session.pendingText, extractSlackErrorCode(err) ?? "unknown");
|
|
129
|
-
throw err;
|
|
130
|
-
}
|
|
131
|
-
}
|
|
132
|
-
/**
|
|
133
|
-
* Stop (finalize) a Slack stream.
|
|
134
|
-
*
|
|
135
|
-
* After calling this the stream message becomes a normal Slack message.
|
|
136
|
-
* Optionally include final text to append before stopping.
|
|
137
|
-
*
|
|
138
|
-
* If Slack's `chat.stopStream` responds with a definitive recipient/channel
|
|
139
|
-
* rejection while text is still buffered locally, this function throws a
|
|
140
|
-
* {@link SlackStreamNotDeliveredError} carrying that pending text so the caller
|
|
141
|
-
* can deliver it through the normal Slack reply path. Ambiguous failures
|
|
142
|
-
* propagate unchanged because Slack may have committed the request.
|
|
143
|
-
*
|
|
144
|
-
* If Slack responds with a known benign finalize error (see
|
|
145
|
-
* {@link BENIGN_SLACK_FINALIZE_ERROR_CODES}) after prior `append` calls already
|
|
146
|
-
* landed, the error is swallowed and the session is marked stopped - the
|
|
147
|
-
* already-delivered text stays visible.
|
|
148
|
-
*
|
|
149
|
-
* Errors without buffered text propagate unchanged.
|
|
150
|
-
*
|
|
151
|
-
* On success, returns the finalized message's Slack `ts` (when reported) so the
|
|
152
|
-
* caller can emit the `message_sent` hook with a populated `messageId`.
|
|
153
|
-
*/
|
|
154
|
-
async function stopSlackStream(params) {
|
|
155
|
-
const { session, text, chunks, metadata } = params;
|
|
156
|
-
if (session.stopped) {
|
|
157
|
-
logVerbose("slack-stream: stream already stopped, ignoring duplicate stop");
|
|
158
|
-
return {};
|
|
159
|
-
}
|
|
160
|
-
session.stopped = true;
|
|
161
|
-
if (text) session.pendingText += text;
|
|
162
|
-
logVerbose(`slack-stream: stopping stream in ${session.channel} thread=${session.threadTs}${text ? ` (final text: ${text.length} chars)` : ""}`);
|
|
163
|
-
try {
|
|
164
|
-
const stopResponse = await session.streamer.stop(text || chunks?.length || metadata ? {
|
|
165
|
-
...text ? { markdown_text: text } : {},
|
|
166
|
-
...chunks?.length ? { chunks } : {},
|
|
167
|
-
...metadata ? { metadata } : {}
|
|
168
|
-
} : void 0);
|
|
169
|
-
session.delivered = true;
|
|
170
|
-
session.pendingText = "";
|
|
171
|
-
logVerbose("slack-stream: stream stopped");
|
|
172
|
-
const messageId = stopResponse?.ts ?? stopResponse?.message?.ts;
|
|
173
|
-
return messageId ? { messageId } : {};
|
|
174
|
-
} catch (err) {
|
|
175
|
-
const code = extractSlackErrorCode(err) ?? "unknown";
|
|
176
|
-
const benignFinalizeError = isBenignSlackFinalizeError(err);
|
|
177
|
-
if (session.pendingText && (benignFinalizeError || code === "missing_scope")) throw new SlackStreamNotDeliveredError(session.pendingText, code);
|
|
178
|
-
if (benignFinalizeError) {
|
|
179
|
-
if (session.delivered) {
|
|
180
|
-
logVerbose(`slack-stream: finalize rejected by Slack (${code}); prior appends delivered, treating stream as stopped`);
|
|
181
|
-
return {};
|
|
182
|
-
}
|
|
183
|
-
}
|
|
184
|
-
throw err;
|
|
185
|
-
}
|
|
186
|
-
}
|
|
187
|
-
/**
|
|
188
|
-
* Slack API error codes that indicate `chat.stopStream` (or the
|
|
189
|
-
* `chat.startStream` call the SDK issues inside `stop()` when the buffer
|
|
190
|
-
* never flushed) cannot finalize the stream for the current recipient or
|
|
191
|
-
* team. Either the caller falls back to a normal message (see
|
|
192
|
-
* {@link SlackStreamNotDeliveredError}) or, if prior appends already
|
|
193
|
-
* delivered text, the error is logged verbosely and swallowed.
|
|
194
|
-
*/
|
|
195
|
-
const BENIGN_SLACK_FINALIZE_ERROR_CODES = /* @__PURE__ */ new Set([
|
|
196
|
-
"user_not_found",
|
|
197
|
-
"team_not_found",
|
|
198
|
-
"missing_recipient_user_id",
|
|
199
|
-
"method_not_supported_for_channel_type"
|
|
200
|
-
]);
|
|
201
|
-
function isBenignSlackFinalizeError(err) {
|
|
202
|
-
const code = extractSlackErrorCode(err);
|
|
203
|
-
return code !== void 0 && BENIGN_SLACK_FINALIZE_ERROR_CODES.has(code);
|
|
204
|
-
}
|
|
205
|
-
function extractSlackErrorCode(err) {
|
|
206
|
-
if (!err || typeof err !== "object") return;
|
|
207
|
-
const record = err;
|
|
208
|
-
if (record.data && typeof record.data === "object") {
|
|
209
|
-
const inner = record.data.error;
|
|
210
|
-
if (typeof inner === "string") return inner;
|
|
211
|
-
}
|
|
212
|
-
return (typeof record.message === "string" ? record.message : "").match(/An API error occurred:\s*([a-z_][a-z0-9_]*)/i)?.[1];
|
|
213
|
-
}
|
|
214
|
-
function markSlackStreamFallbackDelivered(session) {
|
|
215
|
-
const nativeStreamWasStarted = session.delivered;
|
|
216
|
-
session.pendingText = "";
|
|
217
|
-
session.streamer.buffer = "";
|
|
218
|
-
session.stopped = !nativeStreamWasStarted;
|
|
219
|
-
}
|
|
220
|
-
//#endregion
|
|
221
|
-
//#region extensions/slack/src/monitor/message-handler/timestamp.ts
|
|
222
|
-
const SLACK_TIMESTAMP_RE = /^\d+(?:\.\d+)?$/;
|
|
223
|
-
const MAX_SAFE_SLACK_TIMESTAMP_SECONDS = Number.MAX_SAFE_INTEGER / 1e3;
|
|
224
|
-
function resolveSlackTimestampMs(ts) {
|
|
225
|
-
const trimmed = ts?.trim();
|
|
226
|
-
if (!trimmed || !SLACK_TIMESTAMP_RE.test(trimmed)) return;
|
|
227
|
-
const seconds = asFiniteNumberInRange(parseStrictFiniteNumber(trimmed), {
|
|
228
|
-
min: 0,
|
|
229
|
-
max: MAX_SAFE_SLACK_TIMESTAMP_SECONDS
|
|
230
|
-
});
|
|
231
|
-
return seconds === void 0 ? void 0 : Math.round(seconds * 1e3);
|
|
232
|
-
}
|
|
233
|
-
//#endregion
|
|
234
|
-
//#region extensions/slack/src/monitor/message-handler/dispatch-helpers.ts
|
|
235
|
-
function resolveSlackMessageTimestampMs(message) {
|
|
236
|
-
return resolveSlackTimestampMs(message.event_ts ?? message.ts);
|
|
237
|
-
}
|
|
238
|
-
function resolveSlackBotLoopProtection(prepared) {
|
|
239
|
-
const senderBotId = prepared.message.bot_id;
|
|
240
|
-
if (!senderBotId) return;
|
|
241
|
-
const receiverBotId = prepared.ctx.botId || prepared.ctx.botUserId;
|
|
242
|
-
if (!receiverBotId || senderBotId === prepared.ctx.botId || prepared.message.user === prepared.ctx.botUserId) return;
|
|
243
|
-
return {
|
|
244
|
-
scopeId: prepared.route.accountId,
|
|
245
|
-
conversationId: prepared.message.channel,
|
|
246
|
-
senderId: senderBotId,
|
|
247
|
-
receiverId: receiverBotId,
|
|
248
|
-
config: mergePairLoopGuardConfig(prepared.account.config.botLoopProtection, prepared.channelConfig?.botLoopProtection),
|
|
249
|
-
defaultsConfig: prepared.ctx.cfg.channels?.defaults?.botLoopProtection,
|
|
250
|
-
defaultEnabled: true,
|
|
251
|
-
nowMs: resolveSlackMessageTimestampMs(prepared.message)
|
|
252
|
-
};
|
|
253
|
-
}
|
|
254
|
-
function isSlackStreamingEnabled(params) {
|
|
255
|
-
if (params.mode === "partial") return params.nativeStreaming;
|
|
256
|
-
if (params.mode === "progress") return params.nativeStreaming && params.nativeProgressTaskCards === true;
|
|
257
|
-
return false;
|
|
258
|
-
}
|
|
259
|
-
function shouldEnableSlackPreviewStreaming(params) {
|
|
260
|
-
return params.mode !== "off";
|
|
261
|
-
}
|
|
262
|
-
function shouldInitializeSlackDraftStream(params) {
|
|
263
|
-
return params.previewStreamingEnabled && !params.useStreaming;
|
|
264
|
-
}
|
|
265
|
-
function resolveSlackDisableBlockStreaming(params) {
|
|
266
|
-
if (params.useStreaming || params.shouldUseDraftStream) return true;
|
|
267
|
-
return typeof params.blockStreamingEnabled === "boolean" ? !params.blockStreamingEnabled : void 0;
|
|
268
|
-
}
|
|
269
|
-
function resolveExplicitSlackProgressTitle(entry) {
|
|
270
|
-
const label = resolveChannelProgressDraftConfig(entry).label;
|
|
271
|
-
if (typeof label !== "string") return;
|
|
272
|
-
const trimmed = label.trim();
|
|
273
|
-
return trimmed && trimmed.toLowerCase() !== "auto" ? trimmed : void 0;
|
|
274
|
-
}
|
|
275
|
-
function resolveSlackNativeProgressTaskCards(entry) {
|
|
276
|
-
const streaming = entry?.streaming;
|
|
277
|
-
if (!streaming || typeof streaming !== "object" || Array.isArray(streaming)) return false;
|
|
278
|
-
const progressConfig = streaming.progress;
|
|
279
|
-
return Boolean(progressConfig) && typeof progressConfig === "object" && !Array.isArray(progressConfig) && progressConfig.nativeTaskCards === true;
|
|
280
|
-
}
|
|
281
|
-
function resolveSlackStreamingThreadHint(params) {
|
|
282
|
-
return resolveSlackThreadTs({
|
|
283
|
-
replyToMode: params.replyToMode,
|
|
284
|
-
incomingThreadTs: params.incomingThreadTs,
|
|
285
|
-
messageTs: params.messageTs,
|
|
286
|
-
hasReplied: false,
|
|
287
|
-
isThreadReply: params.isThreadReply
|
|
288
|
-
});
|
|
289
|
-
}
|
|
290
|
-
const SLACK_STREAM_RECIPIENT_TEAM_CACHE_MAX = 2e3;
|
|
291
|
-
const slackStreamRecipientTeamCaches = /* @__PURE__ */ new WeakMap();
|
|
292
|
-
function getSlackStreamRecipientTeamCache(client) {
|
|
293
|
-
const existing = slackStreamRecipientTeamCaches.get(client);
|
|
294
|
-
if (existing) return existing;
|
|
295
|
-
const cache = /* @__PURE__ */ new Map();
|
|
296
|
-
slackStreamRecipientTeamCaches.set(client, cache);
|
|
297
|
-
return cache;
|
|
298
|
-
}
|
|
299
|
-
function buildSlackEventDeliveryKey(params) {
|
|
300
|
-
const reply = resolveSendableOutboundReplyParts(params.payload, { text: params.textOverride });
|
|
301
|
-
const renderPlan = resolveSlackReplyRenderPlan(params.payload, params.textOverride ?? params.payload.text);
|
|
302
|
-
const plannedBlocks = renderPlan.mode === "single" ? renderPlan.blocks : renderPlan.blockPart?.blocks;
|
|
303
|
-
const slackBlocks = readSlackReplyBlocks(params.payload) ?? plannedBlocks;
|
|
304
|
-
const renderedText = renderPlan.mode === "single" ? renderPlan.text : renderPlan.fallbackText;
|
|
305
|
-
if (!reply.hasContent && !slackBlocks?.length && !renderedText.trim()) return null;
|
|
306
|
-
return JSON.stringify({
|
|
307
|
-
kind: params.kind,
|
|
308
|
-
threadTs: params.threadTs ?? "",
|
|
309
|
-
replyToId: params.payload.replyToId ?? null,
|
|
310
|
-
text: renderedText || reply.trimmedText,
|
|
311
|
-
mediaUrls: reply.mediaUrls,
|
|
312
|
-
blocks: slackBlocks ?? null
|
|
313
|
-
});
|
|
314
|
-
}
|
|
315
|
-
function readSlackStreamRecipientTeamCache(params) {
|
|
316
|
-
if (!params.fallbackTeamId || !params.userId) return;
|
|
317
|
-
const cacheKey = `${params.fallbackTeamId}:${params.userId}`;
|
|
318
|
-
const cache = getSlackStreamRecipientTeamCache(params.client);
|
|
319
|
-
const cached = cache.get(cacheKey);
|
|
320
|
-
if (!cached) return;
|
|
321
|
-
cache.delete(cacheKey);
|
|
322
|
-
cache.set(cacheKey, cached);
|
|
323
|
-
return cached;
|
|
324
|
-
}
|
|
325
|
-
function rememberSlackStreamRecipientTeam(params) {
|
|
326
|
-
if (!params.fallbackTeamId || !params.userId) return;
|
|
327
|
-
const cacheKey = `${params.fallbackTeamId}:${params.userId}`;
|
|
328
|
-
const cache = getSlackStreamRecipientTeamCache(params.client);
|
|
329
|
-
if (cache.has(cacheKey)) cache.delete(cacheKey);
|
|
330
|
-
cache.set(cacheKey, params.teamId);
|
|
331
|
-
if (cache.size > SLACK_STREAM_RECIPIENT_TEAM_CACHE_MAX) {
|
|
332
|
-
const oldest = cache.keys().next().value;
|
|
333
|
-
if (oldest) cache.delete(oldest);
|
|
334
|
-
}
|
|
335
|
-
}
|
|
336
|
-
function createSlackEventDeliveryTracker() {
|
|
337
|
-
const deliveredKeys = /* @__PURE__ */ new Set();
|
|
338
|
-
return {
|
|
339
|
-
hasDelivered(params) {
|
|
340
|
-
const key = buildSlackEventDeliveryKey(params);
|
|
341
|
-
return key ? deliveredKeys.has(key) : false;
|
|
342
|
-
},
|
|
343
|
-
markDelivered(params) {
|
|
344
|
-
const key = buildSlackEventDeliveryKey(params);
|
|
345
|
-
if (key) deliveredKeys.add(key);
|
|
346
|
-
}
|
|
347
|
-
};
|
|
348
|
-
}
|
|
349
|
-
function shouldUseStreaming(params) {
|
|
350
|
-
if (!params.streamingEnabled) return false;
|
|
351
|
-
if (!params.threadTs) {
|
|
352
|
-
logVerbose("slack-stream: streaming disabled — no reply thread target available");
|
|
353
|
-
return false;
|
|
354
|
-
}
|
|
355
|
-
return true;
|
|
356
|
-
}
|
|
357
|
-
async function resolveSlackStreamRecipientTeamId(params) {
|
|
358
|
-
const cachedTeamId = readSlackStreamRecipientTeamCache(params);
|
|
359
|
-
if (cachedTeamId) return cachedTeamId;
|
|
360
|
-
if (params.userId) try {
|
|
361
|
-
const info = await params.client.users.info({
|
|
362
|
-
token: params.token,
|
|
363
|
-
user: params.userId
|
|
364
|
-
});
|
|
365
|
-
const teamId = info.user?.team_id ?? info.user?.profile?.team;
|
|
366
|
-
if (teamId) {
|
|
367
|
-
rememberSlackStreamRecipientTeam({
|
|
368
|
-
...params,
|
|
369
|
-
teamId
|
|
370
|
-
});
|
|
371
|
-
return teamId;
|
|
372
|
-
}
|
|
373
|
-
} catch (err) {
|
|
374
|
-
logVerbose(`slack-stream: users.info team lookup failed (${formatErrorMessage(err)})`);
|
|
375
|
-
}
|
|
376
|
-
return params.fallbackTeamId;
|
|
377
|
-
}
|
|
378
|
-
//#endregion
|
|
379
|
-
//#region extensions/slack/src/draft-stream.ts
|
|
380
|
-
const DEFAULT_THROTTLE_MS = 1e3;
|
|
381
|
-
function createSlackDraftStream(params) {
|
|
382
|
-
const maxChars = Math.min(params.maxChars ?? 8e3, SLACK_TEXT_LIMIT);
|
|
383
|
-
const throttleMs = Math.max(250, params.throttleMs ?? DEFAULT_THROTTLE_MS);
|
|
384
|
-
const send = params.send ?? sendMessageSlack;
|
|
385
|
-
const edit = params.edit ?? editSlackMessage;
|
|
386
|
-
const remove = params.remove ?? deleteSlackMessage;
|
|
387
|
-
let streamMessageId;
|
|
388
|
-
let streamChannelId;
|
|
389
|
-
let lastSentKey = "";
|
|
390
|
-
let pendingUpdate;
|
|
391
|
-
let stopped = false;
|
|
392
|
-
const normalizeUpdate = (update) => typeof update === "string" ? { text: update } : update;
|
|
393
|
-
const sendOrEditStreamMessage = async (text) => {
|
|
394
|
-
if (stopped) return;
|
|
395
|
-
const trimmed = text.trimEnd();
|
|
396
|
-
if (!trimmed) return;
|
|
397
|
-
if (trimmed.length > maxChars) {
|
|
398
|
-
stopped = true;
|
|
399
|
-
params.warn?.(`slack stream preview stopped (text length ${trimmed.length} > ${maxChars})`);
|
|
400
|
-
return;
|
|
401
|
-
}
|
|
402
|
-
const update = normalizeUpdate(pendingUpdate ?? text);
|
|
403
|
-
const blocks = update.text === text ? update.blocks : void 0;
|
|
404
|
-
const sentKey = `${trimmed}\n${blocks ? JSON.stringify(blocks) : ""}`;
|
|
405
|
-
if (sentKey === lastSentKey) return;
|
|
406
|
-
lastSentKey = sentKey;
|
|
407
|
-
try {
|
|
408
|
-
if (streamChannelId && streamMessageId) {
|
|
409
|
-
await edit(streamChannelId, streamMessageId, trimmed, {
|
|
410
|
-
cfg: params.cfg,
|
|
411
|
-
token: params.token,
|
|
412
|
-
accountId: params.accountId,
|
|
413
|
-
...params.eventScope ? { client: params.eventScope.client } : {},
|
|
414
|
-
...blocks ? { blocks } : {}
|
|
415
|
-
});
|
|
416
|
-
return;
|
|
417
|
-
}
|
|
418
|
-
const sent = await send(params.target, trimmed, {
|
|
419
|
-
cfg: params.cfg,
|
|
420
|
-
token: params.token,
|
|
421
|
-
accountId: params.accountId,
|
|
422
|
-
threadTs: params.resolveThreadTs?.(),
|
|
423
|
-
identity: params.identity,
|
|
424
|
-
...params.eventScope ? {
|
|
425
|
-
client: params.eventScope.client,
|
|
426
|
-
enterpriseEventScope: params.eventScope
|
|
427
|
-
} : {},
|
|
428
|
-
...params.metadata ? { metadata: params.metadata } : {},
|
|
429
|
-
...blocks ? { blocks } : {}
|
|
430
|
-
});
|
|
431
|
-
streamChannelId = sent.channelId || streamChannelId;
|
|
432
|
-
streamMessageId = sent.messageId || streamMessageId;
|
|
433
|
-
if (!streamChannelId || !streamMessageId) {
|
|
434
|
-
stopped = true;
|
|
435
|
-
params.warn?.("slack stream preview stopped (missing identifiers from sendMessage)");
|
|
436
|
-
return;
|
|
437
|
-
}
|
|
438
|
-
params.onMessageSent?.();
|
|
439
|
-
} catch (err) {
|
|
440
|
-
stopped = true;
|
|
441
|
-
params.warn?.(`slack stream preview failed: ${formatSlackError(err)}`);
|
|
442
|
-
}
|
|
443
|
-
};
|
|
444
|
-
const loop = createDraftStreamLoop({
|
|
445
|
-
throttleMs,
|
|
446
|
-
isStopped: () => stopped,
|
|
447
|
-
sendOrEditStreamMessage
|
|
448
|
-
});
|
|
449
|
-
const stop = () => {
|
|
450
|
-
stopped = true;
|
|
451
|
-
loop.stop();
|
|
452
|
-
};
|
|
453
|
-
const discardPending = async () => {
|
|
454
|
-
stop();
|
|
455
|
-
await loop.waitForInFlight();
|
|
456
|
-
};
|
|
457
|
-
const clear = async () => {
|
|
458
|
-
await discardPending();
|
|
459
|
-
const channelId = streamChannelId;
|
|
460
|
-
const messageId = streamMessageId;
|
|
461
|
-
streamChannelId = void 0;
|
|
462
|
-
streamMessageId = void 0;
|
|
463
|
-
lastSentKey = "";
|
|
464
|
-
pendingUpdate = void 0;
|
|
465
|
-
if (!channelId || !messageId) return;
|
|
466
|
-
try {
|
|
467
|
-
await remove(channelId, messageId, {
|
|
468
|
-
token: params.token,
|
|
469
|
-
accountId: params.accountId,
|
|
470
|
-
...params.eventScope ? { client: params.eventScope.client } : {}
|
|
471
|
-
});
|
|
472
|
-
} catch (err) {
|
|
473
|
-
params.warn?.(`slack stream preview cleanup failed: ${formatSlackError(err)}`);
|
|
474
|
-
}
|
|
475
|
-
};
|
|
476
|
-
const forceNewMessage = () => {
|
|
477
|
-
streamMessageId = void 0;
|
|
478
|
-
streamChannelId = void 0;
|
|
479
|
-
lastSentKey = "";
|
|
480
|
-
pendingUpdate = void 0;
|
|
481
|
-
loop.resetPending();
|
|
482
|
-
};
|
|
483
|
-
params.log?.(`slack stream preview ready (maxChars=${maxChars}, throttleMs=${throttleMs})`);
|
|
484
|
-
return {
|
|
485
|
-
update: (update) => {
|
|
486
|
-
const normalized = normalizeUpdate(update);
|
|
487
|
-
pendingUpdate = update;
|
|
488
|
-
loop.update(normalized.text);
|
|
489
|
-
},
|
|
490
|
-
flush: loop.flush,
|
|
491
|
-
clear,
|
|
492
|
-
discardPending,
|
|
493
|
-
seal: discardPending,
|
|
494
|
-
stop,
|
|
495
|
-
forceNewMessage,
|
|
496
|
-
messageId: () => streamMessageId,
|
|
497
|
-
channelId: () => streamChannelId
|
|
498
|
-
};
|
|
499
|
-
}
|
|
500
|
-
//#endregion
|
|
501
|
-
//#region extensions/slack/src/progress-blocks.ts
|
|
502
|
-
const SLACK_PROGRESS_FIELD_MAX = 1800;
|
|
503
|
-
const DEFAULT_SLACK_PROGRESS_DETAIL_MAX_CHARS = 120;
|
|
504
|
-
const DEFAULT_SLACK_PROGRESS_TASK_DETAIL_MAX_CHARS = 48;
|
|
505
|
-
const SLACK_PROGRESS_CHUNK_TEXT_MAX = 256;
|
|
506
|
-
const SLACK_PROGRESS_TASK_TITLE_MAX = 120;
|
|
507
|
-
const SLACK_PROGRESS_PLAN_FALLBACK_TITLE = "Thinking";
|
|
508
|
-
function field(text) {
|
|
509
|
-
return {
|
|
510
|
-
type: "mrkdwn",
|
|
511
|
-
text: truncateSlackText(text, SLACK_PROGRESS_FIELD_MAX)
|
|
512
|
-
};
|
|
513
|
-
}
|
|
514
|
-
function resolveMaxLineChars(value, fallback) {
|
|
515
|
-
return value && value > 0 ? Math.floor(value) : fallback;
|
|
516
|
-
}
|
|
517
|
-
function compactDetail(value, maxChars) {
|
|
518
|
-
const normalized = value.replace(/\s+/g, " ").trim();
|
|
519
|
-
const chars = Array.from(normalized);
|
|
520
|
-
if (chars.length <= maxChars) return normalized;
|
|
521
|
-
if (maxChars <= 1) return "…";
|
|
522
|
-
const keepStart = Math.max(1, Math.ceil((maxChars - 1) * .45));
|
|
523
|
-
const keepEnd = Math.max(1, maxChars - keepStart - 1);
|
|
524
|
-
return `${chars.slice(0, keepStart).join("").trimEnd()}…${chars.slice(-keepEnd).join("").trimStart()}`;
|
|
525
|
-
}
|
|
526
|
-
function compactTitle(value) {
|
|
527
|
-
return truncateSlackText(value.replace(/\s+/g, " ").trim(), SLACK_PROGRESS_TASK_TITLE_MAX);
|
|
528
|
-
}
|
|
529
|
-
function compactChunkText(value) {
|
|
530
|
-
return truncateSlackText(value.replace(/\s+/g, " ").trim(), SLACK_PROGRESS_CHUNK_TEXT_MAX);
|
|
531
|
-
}
|
|
532
|
-
function lineDetailParts(line) {
|
|
533
|
-
return [line.detail, line.status && line.status !== "completed" && !line.detail?.includes(line.status) ? line.status : void 0].map((part) => part?.trim()).filter((part) => Boolean(part));
|
|
534
|
-
}
|
|
535
|
-
function legacyLineTitle(line) {
|
|
536
|
-
return `${line.icon ?? "•"} *${escapeSlackMrkdwn(line.label)}*`;
|
|
537
|
-
}
|
|
538
|
-
function legacyLineDetail(line, maxChars) {
|
|
539
|
-
const detail = lineDetailParts(line).join(" · ");
|
|
540
|
-
return detail ? escapeSlackMrkdwn(compactDetail(detail, maxChars)) : "—";
|
|
541
|
-
}
|
|
542
|
-
function lineTaskTitle(line, maxLineChars) {
|
|
543
|
-
const label = line.label.replace(/\s+/g, " ").trim() || line.toolName || line.kind || "Update";
|
|
544
|
-
const detail = lineDetailParts(line).join(" · ") || line.status?.trim();
|
|
545
|
-
const fallback = line.text.replace(/\s+/g, " ").trim();
|
|
546
|
-
if (detail) return compactTitle(`${label} — ${compactDetail(detail, maxLineChars)}`);
|
|
547
|
-
if (fallback && fallback !== label) return compactTitle(fallback);
|
|
548
|
-
return compactTitle(label);
|
|
549
|
-
}
|
|
550
|
-
function lineTaskStatus(line) {
|
|
551
|
-
const normalized = line.status?.replace(/\s+/g, " ").trim().toLowerCase();
|
|
552
|
-
if (!normalized) return "in_progress";
|
|
553
|
-
if (normalized === "complete" || normalized === "completed" || normalized === "done" || normalized === "ok" || normalized === "success" || normalized === "succeeded" || normalized === "successful" || normalized === "exit 0") return "complete";
|
|
554
|
-
if (normalized === "error" || normalized === "failed" || normalized === "failure" || normalized.startsWith("exit ")) return normalized === "exit 0" ? "complete" : "error";
|
|
555
|
-
return "in_progress";
|
|
556
|
-
}
|
|
557
|
-
function slugTaskIdPart(value) {
|
|
558
|
-
return value?.trim().toLowerCase().replace(/[^a-z0-9]+/g, "_").replace(/^_+|_+$/g, "") || "task";
|
|
559
|
-
}
|
|
560
|
-
function stableTaskIdPart(value, slugValue = value) {
|
|
561
|
-
const suffix = createHash("sha256").update(value).digest("hex").slice(0, 8);
|
|
562
|
-
return `${slugTaskIdPart(slugValue).slice(0, 48)}_${suffix}`;
|
|
563
|
-
}
|
|
564
|
-
function resolveLineTaskIdentity(line) {
|
|
565
|
-
if (line.id?.trim()) return {
|
|
566
|
-
id: stableTaskIdPart(line.id),
|
|
567
|
-
contentDerived: false
|
|
568
|
-
};
|
|
569
|
-
return {
|
|
570
|
-
id: stableTaskIdPart([
|
|
571
|
-
line.kind,
|
|
572
|
-
line.toolName,
|
|
573
|
-
line.label,
|
|
574
|
-
line.text
|
|
575
|
-
].join("\0"), line.toolName ?? line.kind ?? line.label),
|
|
576
|
-
contentDerived: true
|
|
577
|
-
};
|
|
578
|
-
}
|
|
579
|
-
function buildPlanTasks(params) {
|
|
580
|
-
if (params.plan) return params.plan.slice(-50).map((entry, index) => ({
|
|
581
|
-
id: `plan_step_${index + 1}`,
|
|
582
|
-
title: compactTitle(entry.step),
|
|
583
|
-
status: entry.status === "completed" ? "complete" : entry.status
|
|
584
|
-
}));
|
|
585
|
-
const maxLineChars = resolveMaxLineChars(params.maxLineChars, DEFAULT_SLACK_PROGRESS_TASK_DETAIL_MAX_CHARS);
|
|
586
|
-
const lines = params.lines.slice(-50);
|
|
587
|
-
const identities = lines.map(resolveLineTaskIdentity);
|
|
588
|
-
const contentIdOccurrences = /* @__PURE__ */ new Map();
|
|
589
|
-
return lines.map((line, index) => {
|
|
590
|
-
const identity = identities[index];
|
|
591
|
-
let id = identity.id;
|
|
592
|
-
if (identity.contentDerived) {
|
|
593
|
-
const occurrence = (contentIdOccurrences.get(id) ?? 0) + 1;
|
|
594
|
-
contentIdOccurrences.set(id, occurrence);
|
|
595
|
-
id = `${id}_${occurrence}`;
|
|
596
|
-
}
|
|
597
|
-
return {
|
|
598
|
-
id,
|
|
599
|
-
title: lineTaskTitle(line, maxLineChars),
|
|
600
|
-
status: lineTaskStatus(line)
|
|
601
|
-
};
|
|
602
|
-
});
|
|
603
|
-
}
|
|
604
|
-
function resolvePlanTitle(params) {
|
|
605
|
-
return compactChunkText(params.title?.trim() || params.label?.trim() || params.tasks.at(-1)?.title || SLACK_PROGRESS_PLAN_FALLBACK_TITLE);
|
|
606
|
-
}
|
|
607
|
-
function buildSlackProgressStreamChunks(params) {
|
|
608
|
-
const tasks = buildPlanTasks({
|
|
609
|
-
lines: params.lines,
|
|
610
|
-
plan: params.plan,
|
|
611
|
-
maxLineChars: params.maxLineChars
|
|
612
|
-
});
|
|
613
|
-
if (tasks.length === 0) {
|
|
614
|
-
const title = params.title?.trim() || params.label?.trim();
|
|
615
|
-
return title ? [{
|
|
616
|
-
type: "plan_update",
|
|
617
|
-
title: compactChunkText(title)
|
|
618
|
-
}] : void 0;
|
|
619
|
-
}
|
|
620
|
-
return [{
|
|
621
|
-
type: "plan_update",
|
|
622
|
-
title: resolvePlanTitle({
|
|
623
|
-
label: params.label,
|
|
624
|
-
title: params.title,
|
|
625
|
-
tasks
|
|
626
|
-
})
|
|
627
|
-
}, ...tasks.map((task) => ({
|
|
628
|
-
type: "task_update",
|
|
629
|
-
id: task.id,
|
|
630
|
-
title: task.title,
|
|
631
|
-
status: task.status === "in_progress" ? params.finalInProgressStatus ?? (params.completeInProgress ? "complete" : task.status) : task.status
|
|
632
|
-
}))];
|
|
633
|
-
}
|
|
634
|
-
function buildSlackProgressDraftBlocks(params) {
|
|
635
|
-
const label = params.label?.trim() || params.title?.trim();
|
|
636
|
-
const maxLineChars = resolveMaxLineChars(params.maxLineChars, DEFAULT_SLACK_PROGRESS_DETAIL_MAX_CHARS);
|
|
637
|
-
const planLines = formatPlanChecklistLines(params.plan ?? [], {
|
|
638
|
-
maxLines: 50,
|
|
639
|
-
maxLineChars
|
|
640
|
-
});
|
|
641
|
-
const narration = params.narration?.replace(/\s+/g, " ").trim();
|
|
642
|
-
const headBlocks = [
|
|
643
|
-
...label ? [{
|
|
644
|
-
type: "section",
|
|
645
|
-
text: field(`*${escapeSlackMrkdwn(label)}*`)
|
|
646
|
-
}] : [],
|
|
647
|
-
...narration ? [{
|
|
648
|
-
type: "section",
|
|
649
|
-
text: field(`_${escapeSlackMrkdwn(narration)}_`)
|
|
650
|
-
}] : [],
|
|
651
|
-
...planLines.length > 0 ? [{
|
|
652
|
-
type: "section",
|
|
653
|
-
text: field(planLines.map((line) => escapeSlackMrkdwn(line)).join("\n"))
|
|
654
|
-
}] : []
|
|
655
|
-
].slice(0, 50);
|
|
656
|
-
const lineBudget = Math.max(0, 50 - headBlocks.length);
|
|
657
|
-
const renderedBlocks = [...headBlocks, ...params.lines.slice(-lineBudget).map((line) => ({
|
|
658
|
-
type: "section",
|
|
659
|
-
fields: [field(legacyLineTitle(line)), field(legacyLineDetail(line, maxLineChars))]
|
|
660
|
-
}))];
|
|
661
|
-
return renderedBlocks.length ? renderedBlocks : void 0;
|
|
662
|
-
}
|
|
663
|
-
/**
|
|
664
|
-
* Slack native streams key task rows by persistent id with no removal chunk.
|
|
665
|
-
* When the task source switches representation (tool lines <-> typed plan) or
|
|
666
|
-
* a snapshot drops ids, previously emitted non-terminal rows must receive a
|
|
667
|
-
* final update or they linger in_progress forever.
|
|
668
|
-
*/
|
|
669
|
-
function reconcileSlackNativeTaskChunks(params) {
|
|
670
|
-
const nextTasks = /* @__PURE__ */ new Map();
|
|
671
|
-
for (const chunk of params.chunks ?? []) if (chunk.type === "task_update") nextTasks.set(chunk.id, {
|
|
672
|
-
title: chunk.title,
|
|
673
|
-
status: chunk.status
|
|
674
|
-
});
|
|
675
|
-
const terminalized = [...params.previousTasks].filter(([id, task]) => !nextTasks.has(id) && task.status !== "complete" && task.status !== "error").map(([id, task]) => {
|
|
676
|
-
const entry = {
|
|
677
|
-
title: task.title,
|
|
678
|
-
status: "complete"
|
|
679
|
-
};
|
|
680
|
-
nextTasks.set(id, entry);
|
|
681
|
-
return {
|
|
682
|
-
type: "task_update",
|
|
683
|
-
id,
|
|
684
|
-
title: task.title,
|
|
685
|
-
status: "complete"
|
|
686
|
-
};
|
|
687
|
-
});
|
|
688
|
-
for (const [id, task] of params.previousTasks) if (!nextTasks.has(id)) nextTasks.set(id, task);
|
|
689
|
-
return {
|
|
690
|
-
chunks: params.chunks?.length ? [...params.chunks, ...terminalized] : terminalized.length ? terminalized : params.chunks,
|
|
691
|
-
tasks: nextTasks
|
|
692
|
-
};
|
|
693
|
-
}
|
|
694
|
-
function buildSlackProgressStreamStartChunks(params) {
|
|
695
|
-
return buildSlackProgressStreamChunks(params);
|
|
696
|
-
}
|
|
697
|
-
function buildSlackProgressStreamUpdateChunks(params) {
|
|
698
|
-
return buildSlackProgressStreamChunks(params);
|
|
699
|
-
}
|
|
700
|
-
function buildSlackProgressStreamCompletionChunks(params) {
|
|
701
|
-
return buildSlackProgressStreamChunks({
|
|
702
|
-
...params,
|
|
703
|
-
completeInProgress: true
|
|
704
|
-
});
|
|
705
|
-
}
|
|
706
|
-
//#endregion
|
|
707
|
-
//#region extensions/slack/src/stream-mode.ts
|
|
708
|
-
function resolveSlackStreamingConfig(params) {
|
|
709
|
-
const mode = resolveSlackStreamingMode(params);
|
|
710
|
-
return {
|
|
711
|
-
mode,
|
|
712
|
-
nativeStreaming: resolveSlackNativeStreaming(params),
|
|
713
|
-
draftMode: mapStreamingModeToSlackLegacyDraftStreamMode(mode)
|
|
714
|
-
};
|
|
715
|
-
}
|
|
716
|
-
function applyAppendOnlyStreamUpdate(params) {
|
|
717
|
-
const incoming = params.incoming.trimEnd();
|
|
718
|
-
if (!incoming) return {
|
|
719
|
-
rendered: params.rendered,
|
|
720
|
-
source: params.source,
|
|
721
|
-
changed: false
|
|
722
|
-
};
|
|
723
|
-
if (!params.rendered) return {
|
|
724
|
-
rendered: incoming,
|
|
725
|
-
source: incoming,
|
|
726
|
-
changed: true
|
|
727
|
-
};
|
|
728
|
-
if (incoming === params.source) return {
|
|
729
|
-
rendered: params.rendered,
|
|
730
|
-
source: params.source,
|
|
731
|
-
changed: false
|
|
732
|
-
};
|
|
733
|
-
if (incoming.startsWith(params.source) || incoming.startsWith(params.rendered)) return {
|
|
734
|
-
rendered: incoming,
|
|
735
|
-
source: incoming,
|
|
736
|
-
changed: incoming !== params.rendered
|
|
737
|
-
};
|
|
738
|
-
if (params.source.startsWith(incoming)) return {
|
|
739
|
-
rendered: params.rendered,
|
|
740
|
-
source: params.source,
|
|
741
|
-
changed: false
|
|
742
|
-
};
|
|
743
|
-
const separator = params.rendered.endsWith("\n") ? "" : "\n";
|
|
744
|
-
return {
|
|
745
|
-
rendered: `${params.rendered}${separator}${incoming}`,
|
|
746
|
-
source: incoming,
|
|
747
|
-
changed: true
|
|
748
|
-
};
|
|
749
|
-
}
|
|
750
|
-
//#endregion
|
|
751
|
-
//#region extensions/slack/src/monitor/message-handler/preview-finalize.ts
|
|
752
|
-
function buildExpectedSlackEditText(params) {
|
|
753
|
-
const trimmedText = params.text.trim();
|
|
754
|
-
if (trimmedText) return normalizeSlackOutboundText(trimmedText);
|
|
755
|
-
if (params.blocks?.length) return normalizeSlackOutboundText(buildSlackBlocksFallbackText(params.blocks));
|
|
756
|
-
return " ";
|
|
757
|
-
}
|
|
758
|
-
function buildAcceptedSlackEditTexts(params) {
|
|
759
|
-
const expected = buildExpectedSlackEditText(params);
|
|
760
|
-
const texts = /* @__PURE__ */ new Set([
|
|
761
|
-
expected,
|
|
762
|
-
normalizeSlackOutboundText(truncateSlackTextByUtf8Bytes(expected, SLACK_EDIT_TEXT_MAX_BYTES)),
|
|
763
|
-
normalizeSlackOutboundText(buildSlackEditTextPayload(params.text, params.blocks))
|
|
764
|
-
]);
|
|
765
|
-
if (params.blocks?.length && hasSlackNativeDataBlock(params.blocks)) {
|
|
766
|
-
const fallbackPlan = buildSlackNativeDataDeliveryPlan({
|
|
767
|
-
baseText: params.text,
|
|
768
|
-
blocks: params.blocks
|
|
769
|
-
});
|
|
770
|
-
for (const message of fallbackPlan.fallbackMessages) texts.add(normalizeSlackOutboundText(message.text));
|
|
771
|
-
}
|
|
772
|
-
return texts;
|
|
773
|
-
}
|
|
774
|
-
function blocksMatch(expected, actual) {
|
|
775
|
-
if (!expected?.length) return !actual?.length;
|
|
776
|
-
if (!actual?.length) {
|
|
777
|
-
if (!hasSlackNativeDataBlock(expected)) return false;
|
|
778
|
-
return buildSlackNativeDataDeliveryPlan({ blocks: expected }).fallbackMessages.every((message) => !message.blocks?.length);
|
|
779
|
-
}
|
|
780
|
-
if (JSON.stringify(expected) === JSON.stringify(actual)) return true;
|
|
781
|
-
if (!hasSlackNativeDataBlock(expected)) return false;
|
|
782
|
-
try {
|
|
783
|
-
const fallbackPlan = buildSlackNativeDataDeliveryPlan({ blocks: expected });
|
|
784
|
-
const fallbackBlocks = fallbackPlan.fallbackMessages.flatMap((message) => message.blocks ?? []);
|
|
785
|
-
if (JSON.stringify(fallbackBlocks) === JSON.stringify(actual)) return true;
|
|
786
|
-
const fallbackText = fallbackPlan.fallbackMessages.map((message) => message.text).filter(Boolean).join("\n\n");
|
|
787
|
-
return normalizeSlackOutboundText(buildSlackBlocksFallbackText(actual)) === normalizeSlackOutboundText(fallbackText);
|
|
788
|
-
} catch {
|
|
789
|
-
return false;
|
|
790
|
-
}
|
|
791
|
-
}
|
|
792
|
-
async function readSlackMessageAfterEditError(params) {
|
|
793
|
-
if (params.threadTs) return ((await params.client.conversations.replies({
|
|
794
|
-
token: params.token,
|
|
795
|
-
channel: params.channelId,
|
|
796
|
-
ts: params.threadTs,
|
|
797
|
-
latest: params.messageId,
|
|
798
|
-
inclusive: true,
|
|
799
|
-
limit: 100
|
|
800
|
-
})).messages ?? []).find((message) => message?.ts === params.messageId) ?? null;
|
|
801
|
-
const message = (await params.client.conversations.history({
|
|
802
|
-
token: params.token,
|
|
803
|
-
channel: params.channelId,
|
|
804
|
-
latest: params.messageId,
|
|
805
|
-
oldest: params.messageId,
|
|
806
|
-
inclusive: true,
|
|
807
|
-
limit: 1
|
|
808
|
-
})).messages?.[0];
|
|
809
|
-
if (!message?.ts || message.ts !== params.messageId) return null;
|
|
810
|
-
return message;
|
|
811
|
-
}
|
|
812
|
-
async function didSlackPreviewEditApplyAfterError(params) {
|
|
813
|
-
const readback = await readSlackMessageAfterEditError(params);
|
|
814
|
-
if (!readback) return false;
|
|
815
|
-
const expectedText = buildExpectedSlackEditText({
|
|
816
|
-
text: params.text,
|
|
817
|
-
blocks: params.blocks
|
|
818
|
-
});
|
|
819
|
-
const acceptedTexts = buildAcceptedSlackEditTexts({
|
|
820
|
-
text: params.text,
|
|
821
|
-
blocks: params.blocks
|
|
822
|
-
});
|
|
823
|
-
const actualText = normalizeSlackOutboundText((readback.text ?? "").trim());
|
|
824
|
-
if (params.blocks?.length) return acceptedTexts.has(actualText) && blocksMatch(params.blocks, readback.blocks);
|
|
825
|
-
return actualText === expectedText;
|
|
826
|
-
}
|
|
827
|
-
async function finalizeSlackPreviewEdit(params) {
|
|
828
|
-
try {
|
|
829
|
-
await editSlackMessage(params.channelId, params.messageId, params.text, {
|
|
830
|
-
token: params.token,
|
|
831
|
-
accountId: params.accountId,
|
|
832
|
-
client: params.client,
|
|
833
|
-
...params.blocks?.length ? { blocks: params.blocks } : {}
|
|
834
|
-
});
|
|
835
|
-
} catch (err) {
|
|
836
|
-
try {
|
|
837
|
-
if (await didSlackPreviewEditApplyAfterError({
|
|
838
|
-
client: params.client,
|
|
839
|
-
token: params.token,
|
|
840
|
-
channelId: params.channelId,
|
|
841
|
-
messageId: params.messageId,
|
|
842
|
-
text: params.text,
|
|
843
|
-
blocks: params.blocks,
|
|
844
|
-
threadTs: params.threadTs
|
|
845
|
-
})) {
|
|
846
|
-
logVerbose(`slack: preview final edit response failed but readback matched message ${params.channelId}/${params.messageId}; suppressing duplicate fallback send`);
|
|
847
|
-
return;
|
|
848
|
-
}
|
|
849
|
-
} catch (readbackErr) {
|
|
850
|
-
logVerbose(`slack: preview final edit readback failed (${String(readbackErr)})`);
|
|
851
|
-
}
|
|
852
|
-
throw err;
|
|
853
|
-
}
|
|
854
|
-
}
|
|
855
|
-
//#endregion
|
|
856
|
-
//#region extensions/slack/src/monitor/message-handler/dispatch-progress-io.ts
|
|
857
|
-
async function collapseSlackProgressReceipt(params) {
|
|
858
|
-
const { account, ctx, slackClient } = params.setup;
|
|
859
|
-
try {
|
|
860
|
-
await finalizeSlackPreviewEdit({
|
|
861
|
-
client: slackClient,
|
|
862
|
-
token: ctx.botToken,
|
|
863
|
-
accountId: account.accountId,
|
|
864
|
-
...params.edit
|
|
865
|
-
});
|
|
866
|
-
return true;
|
|
867
|
-
} catch (err) {
|
|
868
|
-
logVerbose(`slack: progress receipt edit failed (${formatSlackError(err)})`);
|
|
869
|
-
return false;
|
|
870
|
-
}
|
|
871
|
-
}
|
|
872
|
-
//#endregion
|
|
873
|
-
//#region extensions/slack/src/monitor/message-handler/dispatch-progress-render.ts
|
|
874
|
-
function resolveStructuredProgressLines(lines) {
|
|
875
|
-
return lines.map((line) => {
|
|
876
|
-
if (typeof line !== "string") return line;
|
|
877
|
-
const reasoning = line.startsWith("🧠 ");
|
|
878
|
-
const text = line.replace(/^(?:🧠|💬)\s+/u, "").replace(/^_(.*)_$/su, "$1").trim();
|
|
879
|
-
return {
|
|
880
|
-
...reasoning ? { id: "reasoning" } : {},
|
|
881
|
-
kind: "item",
|
|
882
|
-
text,
|
|
883
|
-
label: reasoning ? "Reasoning" : "Update",
|
|
884
|
-
prefix: false
|
|
885
|
-
};
|
|
886
|
-
});
|
|
887
|
-
}
|
|
888
|
-
function resolveNativeProgressPlan(snapshot) {
|
|
889
|
-
return snapshot.plan?.length ? snapshot.plan : void 0;
|
|
890
|
-
}
|
|
891
|
-
function resolveNativeProgressLines(snapshot) {
|
|
892
|
-
const lines = resolveStructuredProgressLines(snapshot.lines);
|
|
893
|
-
if (snapshot.plan?.length || !snapshot.planExplanation) return lines;
|
|
894
|
-
const explanationLine = buildChannelProgressDraftLine({
|
|
895
|
-
event: "plan",
|
|
896
|
-
phase: "update",
|
|
897
|
-
explanation: snapshot.planExplanation
|
|
898
|
-
});
|
|
899
|
-
return explanationLine ? [...lines, explanationLine] : lines;
|
|
900
|
-
}
|
|
901
|
-
function combineProgressHeadlineAndExplanation(headline, explanation) {
|
|
902
|
-
return headline && explanation && headline !== explanation ? `${headline} — ${explanation}` : headline ?? explanation;
|
|
903
|
-
}
|
|
904
|
-
function buildNativeProgressChunks(params) {
|
|
905
|
-
const input = {
|
|
906
|
-
title: params.title,
|
|
907
|
-
lines: resolveNativeProgressLines(params.snapshot),
|
|
908
|
-
plan: resolveNativeProgressPlan(params.snapshot),
|
|
909
|
-
maxLineChars: params.maxLineChars
|
|
910
|
-
};
|
|
911
|
-
return params.streamStarted ? buildSlackProgressStreamUpdateChunks(input) : buildSlackProgressStreamStartChunks(input);
|
|
912
|
-
}
|
|
913
|
-
//#endregion
|
|
914
|
-
//#region extensions/slack/src/monitor/message-handler/dispatch-progress.ts
|
|
915
|
-
function createSlackProgressRuntime(runtimeParams) {
|
|
916
|
-
const { setup, delivery, resetPreviewDeliveryState } = runtimeParams;
|
|
917
|
-
const { account, cfg, ctx, hasSlackCustomIdentity, message, prepared, replyPlan, runtime, slackClient, slackIdentity, slackMessageMetadata, slackStreaming, slackStreamFallbackTeamId, shouldUseDraftStream, useStreaming, previewStreamingEnabled } = setup;
|
|
918
|
-
const draftStream = shouldUseDraftStream ? createSlackDraftStream({
|
|
919
|
-
target: prepared.replyTarget,
|
|
920
|
-
cfg,
|
|
921
|
-
token: ctx.botToken,
|
|
922
|
-
accountId: account.accountId,
|
|
923
|
-
...prepared.eventScope ? { eventScope: prepared.eventScope } : {},
|
|
924
|
-
...!hasSlackCustomIdentity && slackIdentity ? { identity: slackIdentity } : {},
|
|
925
|
-
...slackMessageMetadata ? { metadata: slackMessageMetadata } : {},
|
|
926
|
-
maxChars: Math.min(ctx.textLimit, SLACK_TEXT_LIMIT),
|
|
927
|
-
resolveThreadTs: () => {
|
|
928
|
-
const ts = replyPlan.peekThreadTs();
|
|
929
|
-
if (ts) delivery.usedReplyThreadTs ??= ts;
|
|
930
|
-
return ts;
|
|
931
|
-
},
|
|
932
|
-
log: logVerbose,
|
|
933
|
-
warn: logVerbose
|
|
934
|
-
}) : void 0;
|
|
935
|
-
let hasStreamedMessage = false;
|
|
936
|
-
const streamMode = slackStreaming.draftMode;
|
|
937
|
-
const useNativeProgressStreaming = useStreaming && slackStreaming.mode === "progress";
|
|
938
|
-
const progressDraftActive = Boolean(draftStream) || useNativeProgressStreaming;
|
|
939
|
-
const previewToolProgressEnabled = progressDraftActive && resolveChannelStreamingPreviewToolProgress(account.config, true, slackStreaming.mode);
|
|
940
|
-
let shouldYieldDraftProgress = () => false;
|
|
941
|
-
const suppressDefaultToolProgressMessages = resolveChannelStreamingSuppressDefaultToolProgressMessages(account.config, {
|
|
942
|
-
draftStreamActive: Boolean(draftStream) || useNativeProgressStreaming,
|
|
943
|
-
previewToolProgressEnabled,
|
|
944
|
-
previewStreamingEnabled
|
|
945
|
-
});
|
|
946
|
-
let previewToolProgressSuppressed = false;
|
|
947
|
-
let legacyPreviewToolProgressLines = [];
|
|
948
|
-
let nativeTaskState = /* @__PURE__ */ new Map();
|
|
949
|
-
let appendRenderedText = "";
|
|
950
|
-
let appendSourceText = "";
|
|
951
|
-
let nativeProgressCompletionSent = false;
|
|
952
|
-
let nativeProgressTerminalStatus = "complete";
|
|
953
|
-
let nativeProgressChunkKey;
|
|
954
|
-
const progressReceipt = createChannelProgressReceiptTracker();
|
|
955
|
-
let progressReceiptCollapsed = false;
|
|
956
|
-
let pendingNativeProgressReceipt;
|
|
957
|
-
const progressSeed = `${account.accountId}:${message.channel}`;
|
|
958
|
-
const useRichProgressDraft = streamMode === "status_final" && resolveChannelProgressDraftRender(account.config) === "rich";
|
|
959
|
-
const explicitProgressTitle = resolveExplicitSlackProgressTitle(account.config);
|
|
960
|
-
const progressDraftMaxLineChars = resolveChannelProgressDraftMaxLineChars(account.config);
|
|
961
|
-
const waitForNativeProgressStreamStart = async () => {
|
|
962
|
-
if (delivery.streamSession || !delivery.nativeProgressStreamStartPromise) return true;
|
|
963
|
-
try {
|
|
964
|
-
await delivery.nativeProgressStreamStartPromise;
|
|
965
|
-
} catch {
|
|
966
|
-
delivery.streamFailed = true;
|
|
967
|
-
return false;
|
|
968
|
-
}
|
|
969
|
-
return !delivery.streamFailed;
|
|
970
|
-
};
|
|
971
|
-
const appendNativeProgressCompletion = async (isError) => {
|
|
972
|
-
const session = delivery.streamSession;
|
|
973
|
-
if (isError) nativeProgressTerminalStatus = "error";
|
|
974
|
-
if (!session || nativeProgressCompletionSent) return;
|
|
975
|
-
const chunks = buildNativeProgressCompletionChunks(isError ? "error" : "complete");
|
|
976
|
-
if (!chunks?.length) return;
|
|
977
|
-
try {
|
|
978
|
-
await appendSlackStream({
|
|
979
|
-
session,
|
|
980
|
-
chunks
|
|
981
|
-
});
|
|
982
|
-
nativeProgressCompletionSent = true;
|
|
983
|
-
delivery.observedReplyDelivery ||= session.delivered;
|
|
984
|
-
} catch (err) {
|
|
985
|
-
delivery.streamFailed = true;
|
|
986
|
-
runtime.error?.(danger(`slack-stream: native progress completion failed: ${formatSlackError(err)}`));
|
|
987
|
-
}
|
|
988
|
-
};
|
|
989
|
-
const buildNativeProgressChunks$1 = (snapshot) => buildNativeProgressChunks({
|
|
990
|
-
snapshot,
|
|
991
|
-
streamStarted: Boolean(delivery.streamSession),
|
|
992
|
-
title: combineProgressHeadlineAndExplanation(explicitProgressTitle ?? snapshot.statusHeadline, snapshot.planExplanation),
|
|
993
|
-
maxLineChars: progressDraftMaxLineChars
|
|
994
|
-
});
|
|
995
|
-
const resolveNativeProgressTitle = (snapshot) => combineProgressHeadlineAndExplanation(explicitProgressTitle ?? snapshot.statusHeadline, snapshot.planExplanation);
|
|
996
|
-
const markNativeProgressDelivered = (session, threadTs) => {
|
|
997
|
-
if (session.delivered) delivery.observedReplyDelivery = true;
|
|
998
|
-
if (threadTs) {
|
|
999
|
-
delivery.usedReplyThreadTs ??= threadTs;
|
|
1000
|
-
delivery.rememberDeliveredThreadTs("block", threadTs);
|
|
1001
|
-
}
|
|
1002
|
-
};
|
|
1003
|
-
const startNativeProgressStream = async (chunks, chunkKey) => {
|
|
1004
|
-
const streamThreadTs = replyPlan.nextThreadTs();
|
|
1005
|
-
if (!streamThreadTs) {
|
|
1006
|
-
logVerbose("slack-stream: no reply thread target for native progress stream start, falling back");
|
|
1007
|
-
delivery.streamFailed = true;
|
|
1008
|
-
return;
|
|
1009
|
-
}
|
|
1010
|
-
delivery.nativeProgressStreamThreadTs = streamThreadTs;
|
|
1011
|
-
const startPromise = (async () => {
|
|
1012
|
-
const session = await startSlackStream({
|
|
1013
|
-
client: slackClient,
|
|
1014
|
-
channel: message.channel,
|
|
1015
|
-
threadTs: streamThreadTs,
|
|
1016
|
-
chunks,
|
|
1017
|
-
taskDisplayMode: "plan",
|
|
1018
|
-
...slackIdentity ? { identity: slackIdentity } : {},
|
|
1019
|
-
teamId: await resolveSlackStreamRecipientTeamId({
|
|
1020
|
-
client: slackClient,
|
|
1021
|
-
token: ctx.botToken,
|
|
1022
|
-
userId: message.user,
|
|
1023
|
-
fallbackTeamId: slackStreamFallbackTeamId
|
|
1024
|
-
}),
|
|
1025
|
-
userId: message.user
|
|
1026
|
-
});
|
|
1027
|
-
delivery.streamSession = session;
|
|
1028
|
-
return session;
|
|
1029
|
-
})();
|
|
1030
|
-
delivery.nativeProgressStreamStartPromise = startPromise;
|
|
1031
|
-
let startedSession;
|
|
1032
|
-
try {
|
|
1033
|
-
startedSession = await startPromise;
|
|
1034
|
-
} finally {
|
|
1035
|
-
if (delivery.nativeProgressStreamStartPromise === startPromise) delivery.nativeProgressStreamStartPromise = null;
|
|
1036
|
-
}
|
|
1037
|
-
if (startedSession) markNativeProgressDelivered(startedSession, streamThreadTs);
|
|
1038
|
-
nativeProgressChunkKey = chunkKey;
|
|
1039
|
-
replyPlan.markSent();
|
|
1040
|
-
};
|
|
1041
|
-
const appendNativeProgressStream = async (chunks, chunkKey) => {
|
|
1042
|
-
if (!delivery.streamSession) return;
|
|
1043
|
-
await appendSlackStream({
|
|
1044
|
-
session: delivery.streamSession,
|
|
1045
|
-
chunks
|
|
1046
|
-
});
|
|
1047
|
-
markNativeProgressDelivered(delivery.streamSession);
|
|
1048
|
-
nativeProgressChunkKey = chunkKey;
|
|
1049
|
-
};
|
|
1050
|
-
const updateNativeProgressStream = async () => {
|
|
1051
|
-
const snapshot = progressDraft.getSnapshot();
|
|
1052
|
-
const progressLines = resolveNativeProgressLines(snapshot);
|
|
1053
|
-
const hasRetirableNativeTasks = [...nativeTaskState.values()].some((task) => task.status !== "complete" && task.status !== "error");
|
|
1054
|
-
if (!useNativeProgressStreaming || delivery.streamFailed || progressLines.length === 0 && !snapshot.plan?.length && !snapshot.statusHeadline && !explicitProgressTitle && !hasRetirableNativeTasks) return;
|
|
1055
|
-
if (!await waitForNativeProgressStreamStart()) return;
|
|
1056
|
-
const reconciled = reconcileSlackNativeTaskChunks({
|
|
1057
|
-
previousTasks: nativeTaskState,
|
|
1058
|
-
chunks: buildNativeProgressChunks$1(snapshot)
|
|
1059
|
-
});
|
|
1060
|
-
const chunks = reconciled.chunks;
|
|
1061
|
-
if (!chunks?.length) return;
|
|
1062
|
-
const chunkKey = JSON.stringify(chunks);
|
|
1063
|
-
if (chunkKey === nativeProgressChunkKey) return;
|
|
1064
|
-
try {
|
|
1065
|
-
if (!delivery.streamSession) await startNativeProgressStream(chunks, chunkKey);
|
|
1066
|
-
else await appendNativeProgressStream(chunks, chunkKey);
|
|
1067
|
-
nativeTaskState = reconciled.tasks;
|
|
1068
|
-
} catch (err) {
|
|
1069
|
-
runtime.error?.(danger(`slack-stream: native progress stream failed: ${formatSlackError(err)}, falling back`));
|
|
1070
|
-
delivery.streamFailed = true;
|
|
1071
|
-
}
|
|
1072
|
-
};
|
|
1073
|
-
const resetProgressTurnState = () => {
|
|
1074
|
-
progressReceipt.reset();
|
|
1075
|
-
progressReceiptCollapsed = false;
|
|
1076
|
-
pendingNativeProgressReceipt = void 0;
|
|
1077
|
-
};
|
|
1078
|
-
const collapseProgressReceipt = async (params) => {
|
|
1079
|
-
progressReceiptCollapsed = await collapseSlackProgressReceipt({
|
|
1080
|
-
setup,
|
|
1081
|
-
edit: params
|
|
1082
|
-
});
|
|
1083
|
-
};
|
|
1084
|
-
const progressDraft = createChannelProgressDraftCompositor({
|
|
1085
|
-
entry: account.config,
|
|
1086
|
-
mode: slackStreaming.mode,
|
|
1087
|
-
active: progressDraftActive && streamMode === "status_final",
|
|
1088
|
-
seed: progressSeed,
|
|
1089
|
-
formatLine: escapeSlackMrkdwn,
|
|
1090
|
-
reasoningLinePrefix: "🧠 ",
|
|
1091
|
-
commentaryLinePrefix: "💬 ",
|
|
1092
|
-
reasoningGate: previewToolProgressEnabled,
|
|
1093
|
-
commentaryItalics: false,
|
|
1094
|
-
updateOnLineChange: useNativeProgressStreaming || useRichProgressDraft,
|
|
1095
|
-
update: async (previewText, options) => {
|
|
1096
|
-
if (useNativeProgressStreaming) {
|
|
1097
|
-
await updateNativeProgressStream();
|
|
1098
|
-
return;
|
|
1099
|
-
}
|
|
1100
|
-
if (!draftStream) return;
|
|
1101
|
-
const snapshot = progressDraft.getSnapshot();
|
|
1102
|
-
const structuredLines = resolveStructuredProgressLines(options?.lines ?? snapshot.lines);
|
|
1103
|
-
const richNarration = combineProgressHeadlineAndExplanation(snapshot.statusHeadline, snapshot.planExplanation);
|
|
1104
|
-
const richProgressBlocks = useRichProgressDraft ? buildSlackProgressDraftBlocks({
|
|
1105
|
-
title: explicitProgressTitle,
|
|
1106
|
-
lines: structuredLines,
|
|
1107
|
-
plan: snapshot.plan,
|
|
1108
|
-
narration: richNarration,
|
|
1109
|
-
maxLineChars: progressDraftMaxLineChars
|
|
1110
|
-
}) : void 0;
|
|
1111
|
-
draftStream.update(useRichProgressDraft && richProgressBlocks ? {
|
|
1112
|
-
text: previewText,
|
|
1113
|
-
blocks: richProgressBlocks
|
|
1114
|
-
} : previewText);
|
|
1115
|
-
hasStreamedMessage = true;
|
|
1116
|
-
if (options?.flush) await draftStream.flush();
|
|
1117
|
-
}
|
|
1118
|
-
});
|
|
1119
|
-
const commentaryProgressEnabled = progressDraft.commentaryProgressEnabled;
|
|
1120
|
-
const buildNativeProgressCompletionChunks = (finalInProgressStatus) => {
|
|
1121
|
-
const snapshot = progressDraft.getSnapshot();
|
|
1122
|
-
const lines = resolveNativeProgressLines(snapshot);
|
|
1123
|
-
const hasRetirableNativeTasks = [...nativeTaskState.values()].some((task) => task.status !== "complete" && task.status !== "error");
|
|
1124
|
-
if (lines.length === 0 && !snapshot.plan?.length && !hasRetirableNativeTasks) return;
|
|
1125
|
-
return reconcileSlackNativeTaskChunks({
|
|
1126
|
-
previousTasks: nativeTaskState,
|
|
1127
|
-
chunks: buildSlackProgressStreamCompletionChunks({
|
|
1128
|
-
title: resolveNativeProgressTitle(snapshot),
|
|
1129
|
-
lines,
|
|
1130
|
-
plan: resolveNativeProgressPlan(snapshot),
|
|
1131
|
-
maxLineChars: progressDraftMaxLineChars,
|
|
1132
|
-
finalInProgressStatus
|
|
1133
|
-
})
|
|
1134
|
-
}).chunks;
|
|
1135
|
-
};
|
|
1136
|
-
const finishNativeProgressTurn = async (completionChunks) => {
|
|
1137
|
-
if (delivery.nativeProgressStreamStartPromise) await delivery.nativeProgressStreamStartPromise.catch(() => null);
|
|
1138
|
-
const session = delivery.streamSession;
|
|
1139
|
-
if (session && !session.stopped) try {
|
|
1140
|
-
if (completionChunks?.length) nativeProgressCompletionSent = true;
|
|
1141
|
-
const stopResult = await stopSlackStream({
|
|
1142
|
-
session,
|
|
1143
|
-
...completionChunks?.length ? { chunks: completionChunks } : {},
|
|
1144
|
-
...slackMessageMetadata ? { metadata: slackMessageMetadata } : {}
|
|
1145
|
-
});
|
|
1146
|
-
delivery.acknowledgeStoppedStreamedDeliveries(session, stopResult?.messageId);
|
|
1147
|
-
if (pendingNativeProgressReceipt && stopResult?.messageId) await collapseProgressReceipt({
|
|
1148
|
-
channelId: session.channel,
|
|
1149
|
-
messageId: stopResult.messageId,
|
|
1150
|
-
text: pendingNativeProgressReceipt,
|
|
1151
|
-
threadTs: session.threadTs
|
|
1152
|
-
});
|
|
1153
|
-
} catch (err) {
|
|
1154
|
-
const error = formatSlackError(err);
|
|
1155
|
-
delivery.emitAcknowledgedStreamedDeliveries();
|
|
1156
|
-
delivery.emitFailedPendingStreamedDeliveries(error);
|
|
1157
|
-
logVerbose(`slack-stream: failed to rotate native progress stream (${error})`);
|
|
1158
|
-
}
|
|
1159
|
-
delivery.streamSession = null;
|
|
1160
|
-
delivery.nativeProgressStreamStartPromise = null;
|
|
1161
|
-
delivery.nativeProgressStreamThreadTs = void 0;
|
|
1162
|
-
delivery.streamFailed = false;
|
|
1163
|
-
};
|
|
1164
|
-
const pushPlanProgress = async (steps, explanation) => {
|
|
1165
|
-
if (streamMode === "status_final") {
|
|
1166
|
-
await progressDraft.pushPlanProgress(steps, { explanation });
|
|
1167
|
-
return;
|
|
1168
|
-
}
|
|
1169
|
-
if (previewToolProgressSuppressed || !draftStream) return;
|
|
1170
|
-
const text = formatChannelProgressDraftText({
|
|
1171
|
-
entry: account.config,
|
|
1172
|
-
lines: legacyPreviewToolProgressLines,
|
|
1173
|
-
seed: progressSeed,
|
|
1174
|
-
formatLine: escapeSlackMrkdwn,
|
|
1175
|
-
narration: explanation,
|
|
1176
|
-
plan: steps
|
|
1177
|
-
});
|
|
1178
|
-
if (text) {
|
|
1179
|
-
draftStream.update(text);
|
|
1180
|
-
hasStreamedMessage = true;
|
|
1181
|
-
}
|
|
1182
|
-
};
|
|
1183
|
-
const pushPreviewProgress = async (line, options) => {
|
|
1184
|
-
if (!draftStream && !useNativeProgressStreaming) return;
|
|
1185
|
-
if (options?.toolName !== void 0 && !isChannelProgressDraftWorkToolName(options.toolName)) return;
|
|
1186
|
-
const normalized = line?.text.replace(/\s+/g, " ").trim();
|
|
1187
|
-
if (streamMode === "status_final") {
|
|
1188
|
-
if (!line || !normalized) {
|
|
1189
|
-
await progressDraft.noteActivity();
|
|
1190
|
-
return;
|
|
1191
|
-
}
|
|
1192
|
-
await progressDraft.pushToolProgress(line, options);
|
|
1193
|
-
return;
|
|
1194
|
-
}
|
|
1195
|
-
if (!line || !normalized || !draftStream || !previewToolProgressEnabled || previewToolProgressSuppressed) return;
|
|
1196
|
-
const nextLines = mergeChannelProgressDraftLine(legacyPreviewToolProgressLines, line, { maxLines: resolveChannelProgressDraftMaxLines(account.config) });
|
|
1197
|
-
if (nextLines === legacyPreviewToolProgressLines) return;
|
|
1198
|
-
legacyPreviewToolProgressLines = nextLines;
|
|
1199
|
-
draftStream.update(formatChannelProgressDraftText({
|
|
1200
|
-
entry: account.config,
|
|
1201
|
-
lines: legacyPreviewToolProgressLines,
|
|
1202
|
-
seed: progressSeed,
|
|
1203
|
-
formatLine: escapeSlackMrkdwn
|
|
1204
|
-
}));
|
|
1205
|
-
hasStreamedMessage = true;
|
|
1206
|
-
};
|
|
1207
|
-
const updateDraftFromPartial = (text) => {
|
|
1208
|
-
const trimmed = text?.trimEnd();
|
|
1209
|
-
if (!trimmed) return;
|
|
1210
|
-
if (streamMode === "append") {
|
|
1211
|
-
previewToolProgressSuppressed = true;
|
|
1212
|
-
legacyPreviewToolProgressLines = [];
|
|
1213
|
-
const next = applyAppendOnlyStreamUpdate({
|
|
1214
|
-
incoming: trimmed,
|
|
1215
|
-
rendered: appendRenderedText,
|
|
1216
|
-
source: appendSourceText
|
|
1217
|
-
});
|
|
1218
|
-
appendRenderedText = next.rendered;
|
|
1219
|
-
appendSourceText = next.source;
|
|
1220
|
-
if (!next.changed) return;
|
|
1221
|
-
draftStream?.update(next.rendered);
|
|
1222
|
-
hasStreamedMessage = true;
|
|
1223
|
-
return;
|
|
1224
|
-
}
|
|
1225
|
-
if (streamMode === "status_final") return;
|
|
1226
|
-
previewToolProgressSuppressed = true;
|
|
1227
|
-
legacyPreviewToolProgressLines = [];
|
|
1228
|
-
draftStream?.update(trimmed);
|
|
1229
|
-
hasStreamedMessage = true;
|
|
1230
|
-
};
|
|
1231
|
-
const pushReasoningProgress = async (payload) => {
|
|
1232
|
-
if (!payload?.text) return;
|
|
1233
|
-
if (streamMode !== "status_final") {
|
|
1234
|
-
const normalized = progressDraft.mergeReasoningProgress(payload.text, { snapshot: payload.isReasoningSnapshot === true }).replace(/^_(.*)_$/su, "$1").trim();
|
|
1235
|
-
if (!normalized) return;
|
|
1236
|
-
await pushPreviewProgress({
|
|
1237
|
-
id: "reasoning",
|
|
1238
|
-
kind: "item",
|
|
1239
|
-
text: normalized,
|
|
1240
|
-
label: "Reasoning"
|
|
1241
|
-
});
|
|
1242
|
-
return;
|
|
1243
|
-
}
|
|
1244
|
-
progressReceipt.noteReasoning();
|
|
1245
|
-
await progressDraft.pushReasoningProgress(payload.text, { snapshot: payload.isReasoningSnapshot === true });
|
|
1246
|
-
};
|
|
1247
|
-
const resetDraftDeliveryState = () => {
|
|
1248
|
-
hasStreamedMessage = false;
|
|
1249
|
-
appendRenderedText = "";
|
|
1250
|
-
appendSourceText = "";
|
|
1251
|
-
};
|
|
1252
|
-
const resetDraftProgressState = () => {
|
|
1253
|
-
progressDraft.resetReasoningProgress();
|
|
1254
|
-
previewToolProgressSuppressed = false;
|
|
1255
|
-
legacyPreviewToolProgressLines = [];
|
|
1256
|
-
};
|
|
1257
|
-
const beginNewProgressTurn = async (options) => {
|
|
1258
|
-
const completionChunks = useNativeProgressStreaming && !nativeProgressCompletionSent ? buildNativeProgressCompletionChunks(nativeProgressTerminalStatus) : void 0;
|
|
1259
|
-
if (!progressDraft.beginNewTurn(options)) return false;
|
|
1260
|
-
if (useNativeProgressStreaming) await finishNativeProgressTurn(completionChunks);
|
|
1261
|
-
else draftStream?.forceNewMessage();
|
|
1262
|
-
resetProgressTurnState();
|
|
1263
|
-
nativeTaskState = /* @__PURE__ */ new Map();
|
|
1264
|
-
nativeProgressCompletionSent = false;
|
|
1265
|
-
nativeProgressTerminalStatus = "complete";
|
|
1266
|
-
nativeProgressChunkKey = void 0;
|
|
1267
|
-
resetPreviewDeliveryState();
|
|
1268
|
-
delivery.resetDeliveryTracker();
|
|
1269
|
-
progressReceiptCollapsed = false;
|
|
1270
|
-
return true;
|
|
1271
|
-
};
|
|
1272
|
-
return {
|
|
1273
|
-
draftStream,
|
|
1274
|
-
streamMode,
|
|
1275
|
-
useNativeProgressStreaming,
|
|
1276
|
-
progressDraftActive,
|
|
1277
|
-
previewToolProgressEnabled,
|
|
1278
|
-
suppressDefaultToolProgressMessages,
|
|
1279
|
-
progressDraft,
|
|
1280
|
-
commentaryProgressEnabled,
|
|
1281
|
-
progressReceipt,
|
|
1282
|
-
get progressReceiptCollapsed() {
|
|
1283
|
-
return progressReceiptCollapsed;
|
|
1284
|
-
},
|
|
1285
|
-
get pendingNativeProgressReceipt() {
|
|
1286
|
-
return pendingNativeProgressReceipt;
|
|
1287
|
-
},
|
|
1288
|
-
set pendingNativeProgressReceipt(value) {
|
|
1289
|
-
pendingNativeProgressReceipt = value;
|
|
1290
|
-
},
|
|
1291
|
-
get nativeProgressCompletionSent() {
|
|
1292
|
-
return nativeProgressCompletionSent;
|
|
1293
|
-
},
|
|
1294
|
-
set nativeProgressCompletionSent(value) {
|
|
1295
|
-
nativeProgressCompletionSent = value;
|
|
1296
|
-
},
|
|
1297
|
-
get nativeProgressTerminalStatus() {
|
|
1298
|
-
return nativeProgressTerminalStatus;
|
|
1299
|
-
},
|
|
1300
|
-
appendNativeProgressCompletion,
|
|
1301
|
-
beginNewProgressTurn,
|
|
1302
|
-
buildNativeProgressCompletionChunks,
|
|
1303
|
-
collapseProgressReceipt,
|
|
1304
|
-
onDraftBoundary: !shouldUseDraftStream && !useNativeProgressStreaming ? void 0 : async () => {
|
|
1305
|
-
if (streamMode === "status_final") {
|
|
1306
|
-
await beginNewProgressTurn();
|
|
1307
|
-
return;
|
|
1308
|
-
}
|
|
1309
|
-
if (hasStreamedMessage) draftStream?.forceNewMessage();
|
|
1310
|
-
resetDraftDeliveryState();
|
|
1311
|
-
resetDraftProgressState();
|
|
1312
|
-
},
|
|
1313
|
-
onQueuedFollowupAdmitted: !shouldUseDraftStream && !useNativeProgressStreaming ? void 0 : async () => {
|
|
1314
|
-
await draftStream?.flush();
|
|
1315
|
-
resetPreviewDeliveryState();
|
|
1316
|
-
if (streamMode === "status_final") await beginNewProgressTurn({ force: true });
|
|
1317
|
-
else draftStream?.forceNewMessage();
|
|
1318
|
-
delivery.resetDeliveryTracker();
|
|
1319
|
-
resetDraftDeliveryState();
|
|
1320
|
-
resetDraftProgressState();
|
|
1321
|
-
},
|
|
1322
|
-
pushPlanProgress,
|
|
1323
|
-
pushPreviewProgress,
|
|
1324
|
-
pushReasoningProgress,
|
|
1325
|
-
updateDraftFromPartial,
|
|
1326
|
-
waitForNativeProgressStreamStart,
|
|
1327
|
-
setShouldYieldDraftProgress: (value) => {
|
|
1328
|
-
shouldYieldDraftProgress = value;
|
|
1329
|
-
},
|
|
1330
|
-
shouldYieldDraftProgress: () => shouldYieldDraftProgress()
|
|
1331
|
-
};
|
|
1332
|
-
}
|
|
1333
|
-
//#endregion
|
|
1334
|
-
//#region extensions/slack/src/threading.ts
|
|
1335
|
-
function resolveSlackThreadContext(params) {
|
|
1336
|
-
const incomingThreadTs = params.message.thread_ts;
|
|
1337
|
-
const eventTs = params.message.event_ts;
|
|
1338
|
-
const messageTs = params.message.ts ?? eventTs;
|
|
1339
|
-
const hasThreadTs = typeof incomingThreadTs === "string" && incomingThreadTs.length > 0;
|
|
1340
|
-
const isThreadReply = hasThreadTs && (incomingThreadTs !== messageTs || Boolean(params.message.parent_user_id));
|
|
1341
|
-
const replyToId = isThreadReply ? incomingThreadTs : void 0;
|
|
1342
|
-
const isAssistantDmThreadRoot = hasThreadTs && !isThreadReply && params.isDirectMessage === true;
|
|
1343
|
-
return {
|
|
1344
|
-
incomingThreadTs,
|
|
1345
|
-
messageTs,
|
|
1346
|
-
isThreadReply,
|
|
1347
|
-
replyToId,
|
|
1348
|
-
messageThreadId: isThreadReply || isAssistantDmThreadRoot ? incomingThreadTs : params.replyToMode === "all" ? messageTs : void 0
|
|
1349
|
-
};
|
|
1350
|
-
}
|
|
1351
|
-
/**
|
|
1352
|
-
* Resolves Slack thread targeting for replies and status indicators.
|
|
1353
|
-
*
|
|
1354
|
-
* @returns replyThreadTs - Thread timestamp for reply messages
|
|
1355
|
-
* @returns statusThreadTs - Thread timestamp for status indicators (typing, etc.)
|
|
1356
|
-
* @returns isThreadReply - true if this is a genuine user reply in a thread,
|
|
1357
|
-
* false if thread_ts comes from a bot status message (e.g. typing indicator)
|
|
1358
|
-
*/
|
|
1359
|
-
function resolveSlackThreadTargets(params) {
|
|
1360
|
-
const { incomingThreadTs, messageTs, isThreadReply } = resolveSlackThreadContext(params);
|
|
1361
|
-
const replyThreadTs = isThreadReply ? incomingThreadTs : params.replyToMode === "all" ? messageTs : void 0;
|
|
1362
|
-
return {
|
|
1363
|
-
replyThreadTs,
|
|
1364
|
-
statusThreadTs: replyThreadTs,
|
|
1365
|
-
isThreadReply
|
|
1366
|
-
};
|
|
1367
|
-
}
|
|
1368
|
-
//#endregion
|
|
1369
|
-
//#region extensions/slack/src/monitor/message-handler/dispatch-setup.ts
|
|
1370
|
-
async function createSlackDispatchSetup(prepared) {
|
|
1371
|
-
const { ctx, account, message, route } = prepared;
|
|
1372
|
-
const slackClient = prepared.eventScope?.client ?? ctx.app.client;
|
|
1373
|
-
const slackStreamFallbackTeamId = prepared.eventScope?.teamId ?? ctx.teamId;
|
|
1374
|
-
const cfg = ctx.cfg;
|
|
1375
|
-
const runtime = ctx.runtime;
|
|
1376
|
-
const outboundIdentity = resolveAgentOutboundIdentity(cfg, route.agentId);
|
|
1377
|
-
const slackIdentity = outboundIdentity ? {
|
|
1378
|
-
username: outboundIdentity.name,
|
|
1379
|
-
iconUrl: outboundIdentity.avatarUrl,
|
|
1380
|
-
iconEmoji: outboundIdentity.emoji
|
|
1381
|
-
} : prepared.relayIdentity;
|
|
1382
|
-
if (prepared.isDirectMessage) {
|
|
1383
|
-
const sessionCfg = cfg.session;
|
|
1384
|
-
const storePath = resolveStorePath(sessionCfg?.store, { agentId: route.agentId });
|
|
1385
|
-
const pinnedMainDmOwner = resolvePinnedMainDmOwnerFromAllowlist({
|
|
1386
|
-
dmScope: cfg.session?.dmScope,
|
|
1387
|
-
allowFrom: ctx.allowFrom,
|
|
1388
|
-
normalizeEntry: normalizeSlackAllowOwnerEntry
|
|
1389
|
-
});
|
|
1390
|
-
const senderRecipient = normalizeOptionalLowercaseString(message.user);
|
|
1391
|
-
const inboundLastRouteSessionKey = resolveInboundLastRouteSessionKey({
|
|
1392
|
-
route,
|
|
1393
|
-
sessionKey: prepared.ctxPayload.SessionKey ?? route.sessionKey
|
|
1394
|
-
});
|
|
1395
|
-
if (inboundLastRouteSessionKey === route.mainSessionKey && pinnedMainDmOwner && senderRecipient && normalizeOptionalLowercaseString(pinnedMainDmOwner) !== senderRecipient) logVerbose(`slack: skip main-session last route for ${senderRecipient} (pinned owner ${pinnedMainDmOwner})`);
|
|
1396
|
-
else await updateLastRoute({
|
|
1397
|
-
storePath,
|
|
1398
|
-
sessionKey: inboundLastRouteSessionKey,
|
|
1399
|
-
deliveryContext: {
|
|
1400
|
-
channel: "slack",
|
|
1401
|
-
to: `user:${message.user}`,
|
|
1402
|
-
accountId: route.accountId,
|
|
1403
|
-
threadId: prepared.ctxPayload.MessageThreadId ?? prepared.ctxPayload.TransportThreadId
|
|
1404
|
-
},
|
|
1405
|
-
ctx: prepared.ctxPayload
|
|
1406
|
-
});
|
|
1407
|
-
}
|
|
1408
|
-
const threadTargets = resolveSlackThreadTargets({
|
|
1409
|
-
message,
|
|
1410
|
-
replyToMode: prepared.replyToMode
|
|
1411
|
-
});
|
|
1412
|
-
const forcedReplyThreadTs = prepared.forcedReplyThreadTs;
|
|
1413
|
-
const slackMessageMetadata = prepared.slackMessageMetadata;
|
|
1414
|
-
const statusThreadTs = forcedReplyThreadTs ?? threadTargets.statusThreadTs;
|
|
1415
|
-
const isThreadReply = threadTargets.isThreadReply;
|
|
1416
|
-
const replyDeliveryMode = forcedReplyThreadTs ? "off" : prepared.replyToMode;
|
|
1417
|
-
const sourceReplyDeliveryMode = resolveChannelMessageSourceReplyDeliveryMode({
|
|
1418
|
-
cfg,
|
|
1419
|
-
ctx: prepared.ctxPayload
|
|
1420
|
-
});
|
|
1421
|
-
const sourceRepliesAreToolOnly = sourceReplyDeliveryMode === "message_tool_only";
|
|
1422
|
-
const suppressRoomEventTyping = prepared.ctxPayload.InboundEventKind === "room_event";
|
|
1423
|
-
const messageSentHookTarget = prepared.ctxPayload.OriginatingTo ?? prepared.ctxPayload.To ?? prepared.replyTarget;
|
|
1424
|
-
const messageSentHookContext = {
|
|
1425
|
-
sessionKeyForInternalHooks: prepared.ctxPayload.SessionKey ?? route.sessionKey,
|
|
1426
|
-
isGroup: prepared.isRoomish,
|
|
1427
|
-
groupId: prepared.isRoomish ? message.channel : void 0
|
|
1428
|
-
};
|
|
1429
|
-
const messageSentDeliveryHookContext = {
|
|
1430
|
-
...messageSentHookContext,
|
|
1431
|
-
messageSentHookTarget
|
|
1432
|
-
};
|
|
1433
|
-
const reactionMessageTs = prepared.ackReactionMessageTs;
|
|
1434
|
-
const messageTs = message.ts ?? message.event_ts;
|
|
1435
|
-
const incomingThreadTs = message.thread_ts;
|
|
1436
|
-
let didSetStatus = false;
|
|
1437
|
-
const statusReactionsEnabled = prepared.ctxPayload.InboundEventKind !== "room_event" && Boolean(prepared.ackReactionPromise) && Boolean(reactionMessageTs) && cfg.messages?.statusReactions?.enabled === true;
|
|
1438
|
-
const statusReactions = createStatusReactionController({
|
|
1439
|
-
enabled: statusReactionsEnabled,
|
|
1440
|
-
adapter: {
|
|
1441
|
-
setReaction: async (emoji) => {
|
|
1442
|
-
await reactSlackMessage(message.channel, reactionMessageTs ?? "", emoji, {
|
|
1443
|
-
token: ctx.botToken,
|
|
1444
|
-
client: slackClient
|
|
1445
|
-
}).catch((err) => {
|
|
1446
|
-
if (formatErrorMessage(err).includes("already_reacted")) return;
|
|
1447
|
-
throw err;
|
|
1448
|
-
});
|
|
1449
|
-
},
|
|
1450
|
-
removeReaction: async (emoji) => {
|
|
1451
|
-
await removeSlackReaction(message.channel, reactionMessageTs ?? "", emoji, {
|
|
1452
|
-
token: ctx.botToken,
|
|
1453
|
-
client: slackClient
|
|
1454
|
-
}).catch((err) => {
|
|
1455
|
-
if (formatErrorMessage(err).includes("no_reaction")) return;
|
|
1456
|
-
throw err;
|
|
1457
|
-
});
|
|
1458
|
-
}
|
|
1459
|
-
},
|
|
1460
|
-
initialEmoji: prepared.ackReactionValue || "eyes",
|
|
1461
|
-
emojis: void 0,
|
|
1462
|
-
timing: DEFAULT_TIMING,
|
|
1463
|
-
onError: (err) => {
|
|
1464
|
-
logAckFailure({
|
|
1465
|
-
log: logVerbose,
|
|
1466
|
-
channel: "slack",
|
|
1467
|
-
target: `${message.channel}/${message.ts}`,
|
|
1468
|
-
error: err
|
|
1469
|
-
});
|
|
1470
|
-
}
|
|
1471
|
-
});
|
|
1472
|
-
if (statusReactionsEnabled) statusReactions.setQueued();
|
|
1473
|
-
const hasRepliedRef = { value: false };
|
|
1474
|
-
const replyPlan = createSlackReplyDeliveryPlan({
|
|
1475
|
-
replyToMode: replyDeliveryMode,
|
|
1476
|
-
incomingThreadTs: forcedReplyThreadTs ?? incomingThreadTs,
|
|
1477
|
-
messageTs,
|
|
1478
|
-
hasRepliedRef,
|
|
1479
|
-
isThreadReply: Boolean(forcedReplyThreadTs) || isThreadReply
|
|
1480
|
-
});
|
|
1481
|
-
const typingTarget = statusThreadTs ? `${message.channel}/${statusThreadTs}` : message.channel;
|
|
1482
|
-
const typingReaction = ctx.typingReaction;
|
|
1483
|
-
const { onModelSelected, ...replyPipeline } = createChannelMessageReplyPipeline({
|
|
1484
|
-
cfg,
|
|
1485
|
-
agentId: route.agentId,
|
|
1486
|
-
channel: "slack",
|
|
1487
|
-
accountId: route.accountId,
|
|
1488
|
-
transformReplyPayload: (payload) => {
|
|
1489
|
-
if (payload.isReasoning === true) return null;
|
|
1490
|
-
return payload;
|
|
1491
|
-
},
|
|
1492
|
-
typing: {
|
|
1493
|
-
start: async () => {
|
|
1494
|
-
didSetStatus = true;
|
|
1495
|
-
await ctx.setSlackThreadStatus({
|
|
1496
|
-
channelId: message.channel,
|
|
1497
|
-
threadTs: statusThreadTs,
|
|
1498
|
-
status: "is typing...",
|
|
1499
|
-
eventScope: prepared.eventScope
|
|
1500
|
-
});
|
|
1501
|
-
if (typingReaction && message.ts) await reactSlackMessage(message.channel, message.ts, typingReaction, {
|
|
1502
|
-
token: ctx.botToken,
|
|
1503
|
-
client: slackClient
|
|
1504
|
-
}).catch((err) => {
|
|
1505
|
-
logVerbose(`slack send: typing reaction failed: ${formatSlackError(err)}`);
|
|
1506
|
-
});
|
|
1507
|
-
},
|
|
1508
|
-
stop: async () => {
|
|
1509
|
-
if (!didSetStatus) return;
|
|
1510
|
-
didSetStatus = false;
|
|
1511
|
-
await ctx.setSlackThreadStatus({
|
|
1512
|
-
channelId: message.channel,
|
|
1513
|
-
threadTs: statusThreadTs,
|
|
1514
|
-
status: "",
|
|
1515
|
-
eventScope: prepared.eventScope
|
|
1516
|
-
});
|
|
1517
|
-
if (typingReaction && message.ts) await removeSlackReaction(message.channel, message.ts, typingReaction, {
|
|
1518
|
-
token: ctx.botToken,
|
|
1519
|
-
client: slackClient
|
|
1520
|
-
}).catch((err) => {
|
|
1521
|
-
logVerbose(`slack send: typing reaction removal failed: ${formatSlackError(err)}`);
|
|
1522
|
-
});
|
|
1523
|
-
},
|
|
1524
|
-
onStartError: (err) => {
|
|
1525
|
-
logTypingFailure({
|
|
1526
|
-
log: (messageValue) => runtime.error?.(danger(messageValue)),
|
|
1527
|
-
channel: "slack",
|
|
1528
|
-
action: "start",
|
|
1529
|
-
target: typingTarget,
|
|
1530
|
-
error: err
|
|
1531
|
-
});
|
|
1532
|
-
},
|
|
1533
|
-
onStopError: (err) => {
|
|
1534
|
-
logTypingFailure({
|
|
1535
|
-
log: (messageLocal) => runtime.error?.(danger(messageLocal)),
|
|
1536
|
-
channel: "slack",
|
|
1537
|
-
action: "stop",
|
|
1538
|
-
target: typingTarget,
|
|
1539
|
-
error: err
|
|
1540
|
-
});
|
|
1541
|
-
}
|
|
1542
|
-
}
|
|
1543
|
-
});
|
|
1544
|
-
const slackStreaming = resolveSlackStreamingConfig({
|
|
1545
|
-
streaming: account.config.streaming,
|
|
1546
|
-
nativeStreaming: resolveChannelStreamingNativeTransport(account.config)
|
|
1547
|
-
});
|
|
1548
|
-
const streamThreadHint = forcedReplyThreadTs ?? resolveSlackStreamingThreadHint({
|
|
1549
|
-
replyToMode: replyDeliveryMode,
|
|
1550
|
-
incomingThreadTs,
|
|
1551
|
-
messageTs,
|
|
1552
|
-
isThreadReply
|
|
1553
|
-
});
|
|
1554
|
-
const hookRunner = getGlobalHookRunner();
|
|
1555
|
-
const allowPreHookProviderStreaming = !((hookRunner?.hasHooks("reply_payload_sending") ?? false) || (hookRunner?.hasHooks("message_sending") ?? false));
|
|
1556
|
-
const previewStreamingEnabled = allowPreHookProviderStreaming && !sourceRepliesAreToolOnly && shouldEnableSlackPreviewStreaming({ mode: slackStreaming.mode });
|
|
1557
|
-
const hasSlackCustomIdentity = Boolean(slackIdentity?.username || slackIdentity?.iconUrl || slackIdentity?.iconEmoji);
|
|
1558
|
-
const useStreaming = shouldUseStreaming({
|
|
1559
|
-
streamingEnabled: !sourceRepliesAreToolOnly && (allowPreHookProviderStreaming || slackStreaming.mode !== "progress") && isSlackStreamingEnabled({
|
|
1560
|
-
mode: slackStreaming.mode,
|
|
1561
|
-
nativeStreaming: slackStreaming.nativeStreaming,
|
|
1562
|
-
nativeProgressTaskCards: resolveSlackNativeProgressTaskCards(account.config)
|
|
1563
|
-
}),
|
|
1564
|
-
threadTs: streamThreadHint
|
|
1565
|
-
});
|
|
1566
|
-
const shouldUseDraftStream = shouldInitializeSlackDraftStream({
|
|
1567
|
-
previewStreamingEnabled,
|
|
1568
|
-
useStreaming
|
|
1569
|
-
});
|
|
1570
|
-
const blockStreamingEnabled = resolveChannelStreamingBlockEnabled(account.config);
|
|
1571
|
-
const disableBlockStreaming = sourceRepliesAreToolOnly ? true : resolveSlackDisableBlockStreaming({
|
|
1572
|
-
useStreaming,
|
|
1573
|
-
shouldUseDraftStream,
|
|
1574
|
-
blockStreamingEnabled
|
|
1575
|
-
});
|
|
1576
|
-
const onSlackDeliveryError = (err, info) => {
|
|
1577
|
-
runtime.error?.(danger(`slack ${info.kind} reply failed: ${formatSlackError(err)}`));
|
|
1578
|
-
replyPipeline.typingCallbacks?.onIdle?.();
|
|
1579
|
-
};
|
|
1580
|
-
return {
|
|
1581
|
-
prepared,
|
|
1582
|
-
ctx,
|
|
1583
|
-
account,
|
|
1584
|
-
message,
|
|
1585
|
-
route,
|
|
1586
|
-
slackClient,
|
|
1587
|
-
slackStreamFallbackTeamId,
|
|
1588
|
-
cfg,
|
|
1589
|
-
runtime,
|
|
1590
|
-
slackIdentity,
|
|
1591
|
-
forcedReplyThreadTs,
|
|
1592
|
-
slackMessageMetadata,
|
|
1593
|
-
statusThreadTs,
|
|
1594
|
-
isThreadReply,
|
|
1595
|
-
replyDeliveryMode,
|
|
1596
|
-
sourceReplyDeliveryMode,
|
|
1597
|
-
sourceRepliesAreToolOnly,
|
|
1598
|
-
suppressRoomEventTyping,
|
|
1599
|
-
messageSentHookTarget,
|
|
1600
|
-
messageSentHookContext,
|
|
1601
|
-
messageSentDeliveryHookContext,
|
|
1602
|
-
incomingThreadTs,
|
|
1603
|
-
messageTs,
|
|
1604
|
-
statusReactionsEnabled,
|
|
1605
|
-
statusReactions,
|
|
1606
|
-
hasRepliedRef,
|
|
1607
|
-
replyPlan,
|
|
1608
|
-
onModelSelected,
|
|
1609
|
-
replyPipeline,
|
|
1610
|
-
slackStreaming,
|
|
1611
|
-
streamThreadHint,
|
|
1612
|
-
previewStreamingEnabled,
|
|
1613
|
-
hasSlackCustomIdentity,
|
|
1614
|
-
shouldUseDraftStream,
|
|
1615
|
-
disableBlockStreaming,
|
|
1616
|
-
useStreaming,
|
|
1617
|
-
onSlackDeliveryError
|
|
1618
|
-
};
|
|
1619
|
-
}
|
|
1620
|
-
//#endregion
|
|
1621
|
-
//#region extensions/slack/src/monitor/message-handler/dispatch-streaming.ts
|
|
1622
|
-
function createSlackStreamingDeliveryRuntime(setup) {
|
|
1623
|
-
const { account, ctx, forcedReplyThreadTs, isThreadReply, message, messageSentDeliveryHookContext, messageSentHookContext, messageSentHookTarget, prepared, replyDeliveryMode, replyPlan, runtime, slackClient, slackIdentity, slackMessageMetadata, slackStreamFallbackTeamId } = setup;
|
|
1624
|
-
const state = {
|
|
1625
|
-
streamSession: null,
|
|
1626
|
-
nativeProgressStreamStartPromise: null,
|
|
1627
|
-
nativeProgressStreamThreadTs: void 0,
|
|
1628
|
-
streamFailed: false,
|
|
1629
|
-
usedReplyThreadTs: void 0,
|
|
1630
|
-
usedBlockReplyThreadTs: void 0,
|
|
1631
|
-
observedReplyDelivery: false,
|
|
1632
|
-
observedFinalReplyDelivery: false
|
|
1633
|
-
};
|
|
1634
|
-
const streamedDeliveries = [];
|
|
1635
|
-
const streamedFailuresOwnedByDispatcher = {
|
|
1636
|
-
tool: 0,
|
|
1637
|
-
block: 0,
|
|
1638
|
-
final: 0
|
|
1639
|
-
};
|
|
1640
|
-
const refreshStreamedAcknowledgements = (session) => {
|
|
1641
|
-
if (session.pendingText.length === 0) for (const delivery of streamedDeliveries) delivery.acknowledged = true;
|
|
1642
|
-
};
|
|
1643
|
-
const recordStreamedDelivery = (kind, content) => {
|
|
1644
|
-
const delivery = {
|
|
1645
|
-
kind,
|
|
1646
|
-
content,
|
|
1647
|
-
acknowledged: false
|
|
1648
|
-
};
|
|
1649
|
-
streamedDeliveries.push(delivery);
|
|
1650
|
-
return delivery;
|
|
1651
|
-
};
|
|
1652
|
-
const rememberStreamedDelivery = (kind, content, session) => {
|
|
1653
|
-
recordStreamedDelivery(kind, content);
|
|
1654
|
-
refreshStreamedAcknowledgements(session);
|
|
1655
|
-
};
|
|
1656
|
-
const emitAcknowledgedStreamedDeliveries = (messageId) => {
|
|
1657
|
-
for (const delivery of streamedDeliveries) {
|
|
1658
|
-
if (!delivery.acknowledged || delivery.outcome) continue;
|
|
1659
|
-
emitSlackMessageSentHooks({
|
|
1660
|
-
...messageSentHookContext,
|
|
1661
|
-
to: messageSentHookTarget,
|
|
1662
|
-
accountId: account.accountId,
|
|
1663
|
-
content: delivery.content,
|
|
1664
|
-
success: true,
|
|
1665
|
-
...messageId ? { messageId } : {}
|
|
1666
|
-
});
|
|
1667
|
-
delivery.outcome = "success";
|
|
1668
|
-
}
|
|
1669
|
-
};
|
|
1670
|
-
const acknowledgeStoppedStreamedDeliveries = (session, messageId) => {
|
|
1671
|
-
refreshStreamedAcknowledgements(session);
|
|
1672
|
-
for (const delivery of streamedDeliveries) delivery.acknowledged = true;
|
|
1673
|
-
emitAcknowledgedStreamedDeliveries(messageId);
|
|
1674
|
-
};
|
|
1675
|
-
const emitFailedPendingStreamedDeliveries = (error) => {
|
|
1676
|
-
for (const delivery of streamedDeliveries) {
|
|
1677
|
-
if (delivery.acknowledged || delivery.outcome) continue;
|
|
1678
|
-
emitSlackMessageSentHooks({
|
|
1679
|
-
...messageSentHookContext,
|
|
1680
|
-
to: messageSentHookTarget,
|
|
1681
|
-
accountId: account.accountId,
|
|
1682
|
-
content: delivery.content,
|
|
1683
|
-
success: false,
|
|
1684
|
-
error
|
|
1685
|
-
});
|
|
1686
|
-
delivery.outcome = "failure";
|
|
1687
|
-
}
|
|
1688
|
-
};
|
|
1689
|
-
const emitSuccessfulPendingStreamedDeliveries = (messageId) => {
|
|
1690
|
-
for (const delivery of streamedDeliveries) {
|
|
1691
|
-
if (delivery.acknowledged || delivery.outcome) continue;
|
|
1692
|
-
emitSlackMessageSentHooks({
|
|
1693
|
-
...messageSentHookContext,
|
|
1694
|
-
to: messageSentHookTarget,
|
|
1695
|
-
accountId: account.accountId,
|
|
1696
|
-
content: delivery.content,
|
|
1697
|
-
success: true,
|
|
1698
|
-
...messageId ? { messageId } : {}
|
|
1699
|
-
});
|
|
1700
|
-
delivery.outcome = "success";
|
|
1701
|
-
}
|
|
1702
|
-
};
|
|
1703
|
-
let deliveryTracker = createSlackEventDeliveryTracker();
|
|
1704
|
-
const markPreviewPayloadDelivered = (params) => {
|
|
1705
|
-
deliveryTracker.markDelivered(params);
|
|
1706
|
-
const nextThreadTs = replyPlan.peekThreadTs();
|
|
1707
|
-
if (nextThreadTs !== params.threadTs) deliveryTracker.markDelivered({
|
|
1708
|
-
...params,
|
|
1709
|
-
threadTs: nextThreadTs
|
|
1710
|
-
});
|
|
1711
|
-
};
|
|
1712
|
-
const resolveDeliveryThreadTs = (params) => {
|
|
1713
|
-
const plannedThreadTs = params.forcedThreadTs ? void 0 : replyPlan.nextThreadTs();
|
|
1714
|
-
return params.forcedThreadTs ?? plannedThreadTs ?? (params.kind === "block" ? state.usedBlockReplyThreadTs : void 0);
|
|
1715
|
-
};
|
|
1716
|
-
const rememberDeliveredThreadTs = (kind, deliveredThreadTs) => {
|
|
1717
|
-
if (!deliveredThreadTs) return;
|
|
1718
|
-
state.usedReplyThreadTs ??= deliveredThreadTs;
|
|
1719
|
-
if (kind === "block") state.usedBlockReplyThreadTs = deliveredThreadTs;
|
|
1720
|
-
};
|
|
1721
|
-
const deliverPendingStreamFallback = async (session, err) => {
|
|
1722
|
-
let fallbackError = err;
|
|
1723
|
-
if (!session.stopped) try {
|
|
1724
|
-
const stopResult = await stopSlackStream({
|
|
1725
|
-
session,
|
|
1726
|
-
...slackMessageMetadata ? { metadata: slackMessageMetadata } : {}
|
|
1727
|
-
});
|
|
1728
|
-
acknowledgeStoppedStreamedDeliveries(session, stopResult.messageId);
|
|
1729
|
-
state.observedReplyDelivery = true;
|
|
1730
|
-
state.usedReplyThreadTs ??= session.threadTs;
|
|
1731
|
-
return true;
|
|
1732
|
-
} catch (stopErr) {
|
|
1733
|
-
if (stopErr instanceof SlackStreamNotDeliveredError) fallbackError = stopErr;
|
|
1734
|
-
else runtime.error?.(danger(`slack-stream: failed to finalize buffered text before fallback: ${formatSlackError(stopErr)}`));
|
|
1735
|
-
}
|
|
1736
|
-
emitAcknowledgedStreamedDeliveries();
|
|
1737
|
-
const fallbackText = fallbackError.pendingText.trim();
|
|
1738
|
-
if (!fallbackText) return false;
|
|
1739
|
-
try {
|
|
1740
|
-
await deliverReplies({
|
|
1741
|
-
cfg: ctx.cfg,
|
|
1742
|
-
replies: [{ text: fallbackText }],
|
|
1743
|
-
target: prepared.replyTarget,
|
|
1744
|
-
token: ctx.botToken,
|
|
1745
|
-
accountId: account.accountId,
|
|
1746
|
-
runtime,
|
|
1747
|
-
textLimit: ctx.textLimit,
|
|
1748
|
-
mediaMaxBytes: ctx.mediaMaxBytes,
|
|
1749
|
-
replyThreadTs: session.threadTs,
|
|
1750
|
-
replyToMode: replyDeliveryMode,
|
|
1751
|
-
...slackIdentity ? { identity: slackIdentity } : {},
|
|
1752
|
-
...slackMessageMetadata ? { metadata: slackMessageMetadata } : {},
|
|
1753
|
-
...messageSentDeliveryHookContext,
|
|
1754
|
-
deferMessageSentHooks: true,
|
|
1755
|
-
...prepared.eventScope ? { eventScope: prepared.eventScope } : {}
|
|
1756
|
-
});
|
|
1757
|
-
markSlackStreamFallbackDelivered(session);
|
|
1758
|
-
if (!session.stopped) try {
|
|
1759
|
-
await stopSlackStream({
|
|
1760
|
-
session,
|
|
1761
|
-
...slackMessageMetadata ? { metadata: slackMessageMetadata } : {}
|
|
1762
|
-
});
|
|
1763
|
-
} catch (finalizeErr) {
|
|
1764
|
-
runtime.error?.(danger(`slack-stream: failed to finalize native stream after fallback delivery: ${formatSlackError(finalizeErr)}`));
|
|
1765
|
-
}
|
|
1766
|
-
emitSuccessfulPendingStreamedDeliveries();
|
|
1767
|
-
state.observedReplyDelivery = true;
|
|
1768
|
-
state.usedReplyThreadTs ??= session.threadTs;
|
|
1769
|
-
logVerbose(`slack-stream: streamed delivery failed (${fallbackError.slackCode}); delivered ${fallbackText.length} chars via deliverReplies fallback`);
|
|
1770
|
-
return true;
|
|
1771
|
-
} catch (postErr) {
|
|
1772
|
-
emitFailedPendingStreamedDeliveries(formatErrorMessage(postErr));
|
|
1773
|
-
runtime.error?.(danger(`slack-stream: fallback deliverReplies failed after ${fallbackError.slackCode}: ${formatErrorMessage(postErr)}`));
|
|
1774
|
-
return false;
|
|
1775
|
-
}
|
|
1776
|
-
};
|
|
1777
|
-
const deliverNormally = async (params) => {
|
|
1778
|
-
if (params.payload.isReasoning === true) return;
|
|
1779
|
-
const replyThreadTs = resolveDeliveryThreadTs(params);
|
|
1780
|
-
const deliveryReplyThreadTs = replyDeliveryMode === "off" && !forcedReplyThreadTs && !isThreadReply ? void 0 : replyThreadTs;
|
|
1781
|
-
if (deliveryTracker.hasDelivered({
|
|
1782
|
-
kind: params.kind,
|
|
1783
|
-
payload: params.payload,
|
|
1784
|
-
threadTs: deliveryReplyThreadTs
|
|
1785
|
-
})) {
|
|
1786
|
-
logVerbose("slack: suppressed duplicate normal delivery within the same turn");
|
|
1787
|
-
return deliveryReplyThreadTs;
|
|
1788
|
-
}
|
|
1789
|
-
await deliverReplies({
|
|
1790
|
-
cfg: ctx.cfg,
|
|
1791
|
-
replies: [params.payload],
|
|
1792
|
-
target: prepared.replyTarget,
|
|
1793
|
-
token: ctx.botToken,
|
|
1794
|
-
accountId: account.accountId,
|
|
1795
|
-
runtime,
|
|
1796
|
-
textLimit: ctx.textLimit,
|
|
1797
|
-
mediaMaxBytes: ctx.mediaMaxBytes,
|
|
1798
|
-
replyThreadTs: deliveryReplyThreadTs,
|
|
1799
|
-
replyToMode: replyDeliveryMode,
|
|
1800
|
-
...slackIdentity ? { identity: slackIdentity } : {},
|
|
1801
|
-
...slackMessageMetadata ? { metadata: slackMessageMetadata } : {},
|
|
1802
|
-
...messageSentDeliveryHookContext,
|
|
1803
|
-
...prepared.eventScope ? { eventScope: prepared.eventScope } : {}
|
|
1804
|
-
});
|
|
1805
|
-
state.observedReplyDelivery = true;
|
|
1806
|
-
if (params.kind === "final") state.observedFinalReplyDelivery = true;
|
|
1807
|
-
const deliveredThreadTs = resolveDeliveredSlackReplyThreadTs({
|
|
1808
|
-
replyToMode: replyDeliveryMode,
|
|
1809
|
-
payloadReplyToId: params.payload.replyToId,
|
|
1810
|
-
replyThreadTs: deliveryReplyThreadTs
|
|
1811
|
-
});
|
|
1812
|
-
rememberDeliveredThreadTs(params.kind, deliveredThreadTs);
|
|
1813
|
-
replyPlan.markSent();
|
|
1814
|
-
deliveryTracker.markDelivered({
|
|
1815
|
-
kind: params.kind,
|
|
1816
|
-
payload: params.payload,
|
|
1817
|
-
threadTs: deliveryReplyThreadTs
|
|
1818
|
-
});
|
|
1819
|
-
return deliveryReplyThreadTs;
|
|
1820
|
-
};
|
|
1821
|
-
const deliverBufferedStreamFallback = async (params) => {
|
|
1822
|
-
if (!await deliverPendingStreamFallback(params.session, params.err)) {
|
|
1823
|
-
streamedFailuresOwnedByDispatcher[params.kind] += 1;
|
|
1824
|
-
return false;
|
|
1825
|
-
}
|
|
1826
|
-
replyPlan.markSent();
|
|
1827
|
-
if (params.kind === "final") state.observedFinalReplyDelivery = true;
|
|
1828
|
-
deliveryTracker.markDelivered({
|
|
1829
|
-
kind: params.kind,
|
|
1830
|
-
payload: params.payload,
|
|
1831
|
-
threadTs: params.session.threadTs,
|
|
1832
|
-
textOverride: params.textOverride
|
|
1833
|
-
});
|
|
1834
|
-
rememberDeliveredThreadTs(params.kind, params.session.threadTs);
|
|
1835
|
-
return true;
|
|
1836
|
-
};
|
|
1837
|
-
const deliverWithStreaming = async (params) => {
|
|
1838
|
-
if (params.payload.isReasoning === true) return;
|
|
1839
|
-
const reply = resolveSendableOutboundReplyParts(params.payload);
|
|
1840
|
-
const renderPlan = resolveSlackReplyRenderPlan(params.payload);
|
|
1841
|
-
const plannedBlocks = renderPlan.mode === "single" ? renderPlan.blocks : renderPlan.blockPart?.blocks;
|
|
1842
|
-
if (state.streamFailed || reply.hasMedia || renderPlan.mode === "split" || Boolean(plannedBlocks?.length) || readSlackReplyBlocks(params.payload)?.length || !reply.hasText) {
|
|
1843
|
-
await deliverNormally({
|
|
1844
|
-
payload: params.payload,
|
|
1845
|
-
kind: params.kind,
|
|
1846
|
-
forcedThreadTs: state.streamSession?.threadTs ?? state.nativeProgressStreamThreadTs
|
|
1847
|
-
});
|
|
1848
|
-
return;
|
|
1849
|
-
}
|
|
1850
|
-
const text = reply.trimmedText;
|
|
1851
|
-
let plannedThreadTs;
|
|
1852
|
-
try {
|
|
1853
|
-
if (!state.streamSession && state.nativeProgressStreamStartPromise) await state.nativeProgressStreamStartPromise;
|
|
1854
|
-
if (state.streamFailed) {
|
|
1855
|
-
await deliverNormally({
|
|
1856
|
-
payload: params.payload,
|
|
1857
|
-
kind: params.kind,
|
|
1858
|
-
forcedThreadTs: state.streamSession?.threadTs ?? state.nativeProgressStreamThreadTs
|
|
1859
|
-
});
|
|
1860
|
-
return;
|
|
1861
|
-
}
|
|
1862
|
-
if (!state.streamSession) {
|
|
1863
|
-
const streamThreadTs = replyPlan.nextThreadTs();
|
|
1864
|
-
plannedThreadTs = streamThreadTs;
|
|
1865
|
-
if (!streamThreadTs) {
|
|
1866
|
-
logVerbose("slack-stream: no reply thread target for stream start, falling back to normal delivery");
|
|
1867
|
-
state.streamFailed = true;
|
|
1868
|
-
await deliverNormally({
|
|
1869
|
-
payload: params.payload,
|
|
1870
|
-
kind: params.kind
|
|
1871
|
-
});
|
|
1872
|
-
return;
|
|
1873
|
-
}
|
|
1874
|
-
if (deliveryTracker.hasDelivered({
|
|
1875
|
-
kind: params.kind,
|
|
1876
|
-
payload: params.payload,
|
|
1877
|
-
threadTs: streamThreadTs,
|
|
1878
|
-
textOverride: text
|
|
1879
|
-
})) {
|
|
1880
|
-
logVerbose("slack-stream: suppressed duplicate stream start payload");
|
|
1881
|
-
return;
|
|
1882
|
-
}
|
|
1883
|
-
state.streamSession = await startSlackStream({
|
|
1884
|
-
client: slackClient,
|
|
1885
|
-
channel: message.channel,
|
|
1886
|
-
threadTs: streamThreadTs,
|
|
1887
|
-
text,
|
|
1888
|
-
...slackIdentity ? { identity: slackIdentity } : {},
|
|
1889
|
-
teamId: await resolveSlackStreamRecipientTeamId({
|
|
1890
|
-
client: slackClient,
|
|
1891
|
-
token: ctx.botToken,
|
|
1892
|
-
userId: message.user,
|
|
1893
|
-
fallbackTeamId: slackStreamFallbackTeamId
|
|
1894
|
-
}),
|
|
1895
|
-
userId: message.user
|
|
1896
|
-
});
|
|
1897
|
-
refreshStreamedAcknowledgements(state.streamSession);
|
|
1898
|
-
if (state.streamSession.delivered) {
|
|
1899
|
-
state.observedReplyDelivery = true;
|
|
1900
|
-
if (params.kind === "final") state.observedFinalReplyDelivery = true;
|
|
1901
|
-
}
|
|
1902
|
-
if (text) rememberStreamedDelivery(params.kind, text, state.streamSession);
|
|
1903
|
-
rememberDeliveredThreadTs(params.kind, streamThreadTs);
|
|
1904
|
-
replyPlan.markSent();
|
|
1905
|
-
deliveryTracker.markDelivered({
|
|
1906
|
-
kind: params.kind,
|
|
1907
|
-
payload: params.payload,
|
|
1908
|
-
threadTs: streamThreadTs,
|
|
1909
|
-
textOverride: text
|
|
1910
|
-
});
|
|
1911
|
-
return;
|
|
1912
|
-
}
|
|
1913
|
-
if (deliveryTracker.hasDelivered({
|
|
1914
|
-
kind: params.kind,
|
|
1915
|
-
payload: params.payload,
|
|
1916
|
-
threadTs: state.streamSession.threadTs,
|
|
1917
|
-
textOverride: text
|
|
1918
|
-
})) {
|
|
1919
|
-
logVerbose("slack-stream: suppressed duplicate append payload");
|
|
1920
|
-
return;
|
|
1921
|
-
}
|
|
1922
|
-
if (text) recordStreamedDelivery(params.kind, text);
|
|
1923
|
-
await appendSlackStream({
|
|
1924
|
-
session: state.streamSession,
|
|
1925
|
-
text: "\n" + text
|
|
1926
|
-
});
|
|
1927
|
-
refreshStreamedAcknowledgements(state.streamSession);
|
|
1928
|
-
if (state.streamSession.delivered) {
|
|
1929
|
-
state.observedReplyDelivery = true;
|
|
1930
|
-
if (params.kind === "final") state.observedFinalReplyDelivery = true;
|
|
1931
|
-
}
|
|
1932
|
-
deliveryTracker.markDelivered({
|
|
1933
|
-
kind: params.kind,
|
|
1934
|
-
payload: params.payload,
|
|
1935
|
-
threadTs: state.streamSession.threadTs,
|
|
1936
|
-
textOverride: text
|
|
1937
|
-
});
|
|
1938
|
-
} catch (err) {
|
|
1939
|
-
if (err instanceof SlackStreamNotDeliveredError) {
|
|
1940
|
-
state.streamFailed = true;
|
|
1941
|
-
if (state.streamSession) {
|
|
1942
|
-
if (await deliverBufferedStreamFallback({
|
|
1943
|
-
session: state.streamSession,
|
|
1944
|
-
err,
|
|
1945
|
-
payload: params.payload,
|
|
1946
|
-
kind: params.kind,
|
|
1947
|
-
textOverride: text
|
|
1948
|
-
})) return;
|
|
1949
|
-
throw err;
|
|
1950
|
-
}
|
|
1951
|
-
await deliverNormally({
|
|
1952
|
-
payload: params.payload,
|
|
1953
|
-
kind: params.kind,
|
|
1954
|
-
forcedThreadTs: plannedThreadTs
|
|
1955
|
-
});
|
|
1956
|
-
return;
|
|
1957
|
-
}
|
|
1958
|
-
runtime.error?.(danger(`slack-stream: streaming API call failed: ${formatSlackError(err)}, falling back`));
|
|
1959
|
-
state.streamFailed = true;
|
|
1960
|
-
if (state.streamSession && state.streamSession.pendingText) {
|
|
1961
|
-
const bufferedFallbackErr = new SlackStreamNotDeliveredError(state.streamSession.pendingText, "unknown");
|
|
1962
|
-
if (await deliverBufferedStreamFallback({
|
|
1963
|
-
session: state.streamSession,
|
|
1964
|
-
err: bufferedFallbackErr,
|
|
1965
|
-
payload: params.payload,
|
|
1966
|
-
kind: params.kind,
|
|
1967
|
-
textOverride: text
|
|
1968
|
-
})) return;
|
|
1969
|
-
throw err;
|
|
1970
|
-
}
|
|
1971
|
-
await deliverNormally({
|
|
1972
|
-
payload: params.payload,
|
|
1973
|
-
kind: params.kind,
|
|
1974
|
-
forcedThreadTs: state.streamSession?.threadTs ?? state.nativeProgressStreamThreadTs ?? plannedThreadTs
|
|
1975
|
-
});
|
|
1976
|
-
}
|
|
1977
|
-
};
|
|
1978
|
-
const reconcileCounts = (counts) => {
|
|
1979
|
-
const next = { ...counts };
|
|
1980
|
-
let changed = false;
|
|
1981
|
-
for (const kind of [
|
|
1982
|
-
"tool",
|
|
1983
|
-
"block",
|
|
1984
|
-
"final"
|
|
1985
|
-
]) {
|
|
1986
|
-
const failedStreamedCount = streamedDeliveries.filter((delivery) => delivery.kind === kind && delivery.outcome === "failure").length;
|
|
1987
|
-
const additionalFailedStreamed = Math.max(0, failedStreamedCount - streamedFailuresOwnedByDispatcher[kind]);
|
|
1988
|
-
if (additionalFailedStreamed > 0) {
|
|
1989
|
-
next[kind] = Math.max(0, (next[kind] ?? 0) - additionalFailedStreamed);
|
|
1990
|
-
changed = true;
|
|
1991
|
-
}
|
|
1992
|
-
}
|
|
1993
|
-
return changed ? next : counts;
|
|
1994
|
-
};
|
|
1995
|
-
return Object.assign(state, {
|
|
1996
|
-
acknowledgeStoppedStreamedDeliveries,
|
|
1997
|
-
deliverNormally,
|
|
1998
|
-
deliverPendingStreamFallback,
|
|
1999
|
-
deliverWithStreaming,
|
|
2000
|
-
emitAcknowledgedStreamedDeliveries,
|
|
2001
|
-
emitFailedPendingStreamedDeliveries,
|
|
2002
|
-
hasDelivered: (params) => deliveryTracker.hasDelivered(params),
|
|
2003
|
-
markPreviewPayloadDelivered,
|
|
2004
|
-
rememberDeliveredThreadTs,
|
|
2005
|
-
reconcileCounts,
|
|
2006
|
-
resetDeliveryTracker: () => {
|
|
2007
|
-
deliveryTracker = createSlackEventDeliveryTracker();
|
|
2008
|
-
}
|
|
2009
|
-
});
|
|
2010
|
-
}
|
|
2011
|
-
//#endregion
|
|
2012
|
-
//#region extensions/slack/src/monitor/message-handler/dispatch.ts
|
|
2013
|
-
async function dispatchPreparedSlackMessage(prepared) {
|
|
2014
|
-
const setup = await createSlackDispatchSetup(prepared);
|
|
2015
|
-
const { account, cfg, ctx, disableBlockStreaming, hasSlackCustomIdentity, hasRepliedRef, message, messageSentHookContext, messageSentHookTarget, onModelSelected, onSlackDeliveryError, previewStreamingEnabled, replyPipeline, replyPlan, route, runtime, slackClient, slackMessageMetadata, slackStreaming, sourceReplyDeliveryMode, statusReactions, statusReactionsEnabled, statusThreadTs, suppressRoomEventTyping, useStreaming } = setup;
|
|
2016
|
-
const delivery = createSlackStreamingDeliveryRuntime(setup);
|
|
2017
|
-
const draftPreviewCommitted = { value: false };
|
|
2018
|
-
const progress = createSlackProgressRuntime({
|
|
2019
|
-
setup,
|
|
2020
|
-
delivery,
|
|
2021
|
-
resetPreviewDeliveryState: () => {
|
|
2022
|
-
draftPreviewCommitted.value = false;
|
|
2023
|
-
delivery.observedFinalReplyDelivery = false;
|
|
2024
|
-
}
|
|
2025
|
-
});
|
|
2026
|
-
const draftStream = progress.draftStream;
|
|
2027
|
-
const deliverSlackPayload = async (payload, info) => {
|
|
2028
|
-
if (payload.isReasoning === true) return { visibleReplySent: false };
|
|
2029
|
-
if (info.kind === "final" && slackStreaming.mode === "progress" && progress.streamMode === "status_final") {
|
|
2030
|
-
const hadProgressDraft = progress.progressDraft.hasStarted;
|
|
2031
|
-
progress.progressDraft.markFinalReplyStarted();
|
|
2032
|
-
if (progress.useNativeProgressStreaming) {
|
|
2033
|
-
await progress.waitForNativeProgressStreamStart();
|
|
2034
|
-
const finalThreadTs = delivery.streamSession?.threadTs ?? delivery.nativeProgressStreamThreadTs;
|
|
2035
|
-
await delivery.deliverNormally({
|
|
2036
|
-
payload,
|
|
2037
|
-
kind: info.kind,
|
|
2038
|
-
forcedThreadTs: finalThreadTs
|
|
2039
|
-
});
|
|
2040
|
-
await progress.appendNativeProgressCompletion(payload.isError === true);
|
|
2041
|
-
progress.progressDraft.markFinalReplyDelivered();
|
|
2042
|
-
if (!payload.isError && hadProgressDraft && delivery.streamSession) progress.pendingNativeProgressReceipt = progress.progressReceipt.buildSummaryLine();
|
|
2043
|
-
return;
|
|
2044
|
-
}
|
|
2045
|
-
if (hadProgressDraft) try {
|
|
2046
|
-
await draftStream?.flush();
|
|
2047
|
-
} catch (err) {
|
|
2048
|
-
logVerbose(`slack: progress draft flush before final failed (${formatSlackError(err)})`);
|
|
2049
|
-
}
|
|
2050
|
-
const receiptChannelId = hadProgressDraft ? draftStream?.channelId() : void 0;
|
|
2051
|
-
const receiptMessageId = hadProgressDraft ? draftStream?.messageId() : void 0;
|
|
2052
|
-
const draftThreadTs = hadProgressDraft ? delivery.usedReplyThreadTs ?? statusThreadTs : void 0;
|
|
2053
|
-
await delivery.deliverNormally({
|
|
2054
|
-
payload,
|
|
2055
|
-
kind: info.kind,
|
|
2056
|
-
...draftThreadTs ? { forcedThreadTs: draftThreadTs } : {}
|
|
2057
|
-
});
|
|
2058
|
-
progress.progressDraft.markFinalReplyDelivered();
|
|
2059
|
-
if (!payload.isError && receiptChannelId && receiptMessageId && !progress.progressReceiptCollapsed) await progress.collapseProgressReceipt({
|
|
2060
|
-
channelId: receiptChannelId,
|
|
2061
|
-
messageId: receiptMessageId,
|
|
2062
|
-
text: progress.progressReceipt.buildSummaryLine(),
|
|
2063
|
-
threadTs: delivery.usedReplyThreadTs ?? statusThreadTs
|
|
2064
|
-
});
|
|
2065
|
-
return;
|
|
2066
|
-
}
|
|
2067
|
-
if (progress.useNativeProgressStreaming) {
|
|
2068
|
-
await delivery.deliverNormally({
|
|
2069
|
-
payload,
|
|
2070
|
-
kind: info.kind,
|
|
2071
|
-
forcedThreadTs: delivery.streamSession?.threadTs ?? delivery.nativeProgressStreamThreadTs
|
|
2072
|
-
});
|
|
2073
|
-
return;
|
|
2074
|
-
}
|
|
2075
|
-
if (useStreaming) {
|
|
2076
|
-
await delivery.deliverWithStreaming({
|
|
2077
|
-
payload,
|
|
2078
|
-
kind: info.kind
|
|
2079
|
-
});
|
|
2080
|
-
return;
|
|
2081
|
-
}
|
|
2082
|
-
const reply = resolveSendableOutboundReplyParts(payload);
|
|
2083
|
-
const ttsSupplement = getReplyPayloadTtsSupplement(payload);
|
|
2084
|
-
const replySourceText = payload.text ?? ttsSupplement?.spokenText;
|
|
2085
|
-
const replyRenderPlan = resolveSlackReplyRenderPlan(payload, replySourceText);
|
|
2086
|
-
const slackBlocks = replyRenderPlan.mode === "single" ? replyRenderPlan.blocks : replyRenderPlan.blockPart?.blocks;
|
|
2087
|
-
const requiresSeparateFallbackDelivery = replyRenderPlan.mode === "split";
|
|
2088
|
-
const trimmedFinalText = replyRenderPlan.mode === "single" ? replyRenderPlan.text.trim() : replyRenderPlan.fallbackText.trim();
|
|
2089
|
-
const previewFinalText = replyRenderPlan.mode === "single" && replyRenderPlan.textIsSlackMrkdwn ? trimmedFinalText : normalizeSlackOutboundText((replySourceText ?? "").trim());
|
|
2090
|
-
const shouldRestoreTtsSupplementTextForPreviewFallback = Boolean(ttsSupplement) && ttsSupplement?.visibleTextAlreadyDelivered !== true && Boolean(draftStream) && !draftPreviewCommitted.value && !delivery.observedFinalReplyDelivery && previewStreamingEnabled && !payload.text?.trim();
|
|
2091
|
-
if (info.kind === "final" && ttsSupplement && draftStream && !hasSlackCustomIdentity && !draftPreviewCommitted.value && !delivery.observedFinalReplyDelivery && previewStreamingEnabled && !payload.isError && !requiresSeparateFallbackDelivery && trimmedFinalText.length > 0) {
|
|
2092
|
-
const channelId = draftStream.channelId();
|
|
2093
|
-
const messageId = draftStream.messageId();
|
|
2094
|
-
if (channelId && messageId) {
|
|
2095
|
-
const finalThreadTs = delivery.usedReplyThreadTs ?? statusThreadTs;
|
|
2096
|
-
await draftStream.flush();
|
|
2097
|
-
await draftStream.seal();
|
|
2098
|
-
try {
|
|
2099
|
-
await finalizeSlackPreviewEdit({
|
|
2100
|
-
client: slackClient,
|
|
2101
|
-
token: ctx.botToken,
|
|
2102
|
-
accountId: account.accountId,
|
|
2103
|
-
channelId,
|
|
2104
|
-
messageId,
|
|
2105
|
-
text: previewFinalText,
|
|
2106
|
-
...slackBlocks?.length ? { blocks: slackBlocks } : {},
|
|
2107
|
-
threadTs: finalThreadTs
|
|
2108
|
-
});
|
|
2109
|
-
} catch (err) {
|
|
2110
|
-
logVerbose(`slack: preview final edit failed; falling back to standard send (${formatSlackError(err)})`);
|
|
2111
|
-
await draftStream.discardPending();
|
|
2112
|
-
let delivered = false;
|
|
2113
|
-
try {
|
|
2114
|
-
await delivery.deliverNormally({
|
|
2115
|
-
payload: payload.text?.trim() ? payload : {
|
|
2116
|
-
...payload,
|
|
2117
|
-
text: ttsSupplement.spokenText
|
|
2118
|
-
},
|
|
2119
|
-
kind: info.kind,
|
|
2120
|
-
forcedThreadTs: finalThreadTs
|
|
2121
|
-
});
|
|
2122
|
-
delivered = true;
|
|
2123
|
-
} finally {
|
|
2124
|
-
if (delivered) await draftStream.clear();
|
|
2125
|
-
}
|
|
2126
|
-
return;
|
|
2127
|
-
}
|
|
2128
|
-
draftPreviewCommitted.value = true;
|
|
2129
|
-
delivery.observedFinalReplyDelivery = true;
|
|
2130
|
-
delivery.observedReplyDelivery = true;
|
|
2131
|
-
replyPlan.markSent();
|
|
2132
|
-
await delivery.deliverNormally({
|
|
2133
|
-
payload: buildTtsSupplementMediaPayload(payload),
|
|
2134
|
-
kind: info.kind,
|
|
2135
|
-
forcedThreadTs: finalThreadTs
|
|
2136
|
-
});
|
|
2137
|
-
delivery.markPreviewPayloadDelivered({
|
|
2138
|
-
kind: info.kind,
|
|
2139
|
-
payload,
|
|
2140
|
-
threadTs: finalThreadTs
|
|
2141
|
-
});
|
|
2142
|
-
return;
|
|
2143
|
-
}
|
|
2144
|
-
}
|
|
2145
|
-
await deliverWithFinalizableLivePreviewAdapter({
|
|
2146
|
-
kind: info.kind,
|
|
2147
|
-
payload,
|
|
2148
|
-
adapter: defineFinalizableLivePreviewAdapter({
|
|
2149
|
-
draft: draftStream && !draftPreviewCommitted.value && !delivery.observedFinalReplyDelivery ? {
|
|
2150
|
-
flush: draftStream.flush,
|
|
2151
|
-
clear: draftStream.clear,
|
|
2152
|
-
discardPending: draftStream.discardPending,
|
|
2153
|
-
seal: draftStream.seal,
|
|
2154
|
-
id: () => {
|
|
2155
|
-
const channelId = draftStream.channelId();
|
|
2156
|
-
const messageId = draftStream.messageId();
|
|
2157
|
-
return channelId && messageId ? {
|
|
2158
|
-
channelId,
|
|
2159
|
-
messageId
|
|
2160
|
-
} : void 0;
|
|
2161
|
-
}
|
|
2162
|
-
} : void 0,
|
|
2163
|
-
buildFinalEdit: () => {
|
|
2164
|
-
if (hasSlackCustomIdentity || !previewStreamingEnabled || reply.hasMedia && !ttsSupplement || payload.isError || requiresSeparateFallbackDelivery || trimmedFinalText.length === 0 && !slackBlocks?.length) return;
|
|
2165
|
-
return {
|
|
2166
|
-
text: previewFinalText,
|
|
2167
|
-
blocks: slackBlocks,
|
|
2168
|
-
threadTs: delivery.usedReplyThreadTs ?? statusThreadTs
|
|
2169
|
-
};
|
|
2170
|
-
},
|
|
2171
|
-
editFinal: async (preview, edit) => {
|
|
2172
|
-
if (delivery.hasDelivered({
|
|
2173
|
-
kind: info.kind,
|
|
2174
|
-
payload,
|
|
2175
|
-
threadTs: edit.threadTs
|
|
2176
|
-
})) return;
|
|
2177
|
-
await finalizeSlackPreviewEdit({
|
|
2178
|
-
client: slackClient,
|
|
2179
|
-
token: ctx.botToken,
|
|
2180
|
-
accountId: account.accountId,
|
|
2181
|
-
channelId: preview.channelId,
|
|
2182
|
-
messageId: preview.messageId,
|
|
2183
|
-
text: edit.text,
|
|
2184
|
-
...edit.blocks?.length ? { blocks: edit.blocks } : {},
|
|
2185
|
-
threadTs: edit.threadTs
|
|
2186
|
-
});
|
|
2187
|
-
if (!ttsSupplement) emitSlackMessageSentHooks({
|
|
2188
|
-
...messageSentHookContext,
|
|
2189
|
-
to: messageSentHookTarget,
|
|
2190
|
-
accountId: account.accountId,
|
|
2191
|
-
content: trimmedFinalText,
|
|
2192
|
-
success: true,
|
|
2193
|
-
messageId: preview.messageId
|
|
2194
|
-
});
|
|
2195
|
-
draftPreviewCommitted.value = true;
|
|
2196
|
-
delivery.observedFinalReplyDelivery = true;
|
|
2197
|
-
},
|
|
2198
|
-
onPreviewFinalized: (_preview) => {
|
|
2199
|
-
draftPreviewCommitted.value = true;
|
|
2200
|
-
delivery.observedFinalReplyDelivery = true;
|
|
2201
|
-
const finalThreadTs = delivery.usedReplyThreadTs ?? statusThreadTs;
|
|
2202
|
-
delivery.observedReplyDelivery = true;
|
|
2203
|
-
replyPlan.markSent();
|
|
2204
|
-
if (!ttsSupplement) delivery.markPreviewPayloadDelivered({
|
|
2205
|
-
kind: info.kind,
|
|
2206
|
-
payload,
|
|
2207
|
-
threadTs: finalThreadTs
|
|
2208
|
-
});
|
|
2209
|
-
},
|
|
2210
|
-
buildSupplementalPayload: () => ttsSupplement ? buildTtsSupplementMediaPayload(payload) : void 0,
|
|
2211
|
-
deliverSupplemental: async (supplementalPayload) => {
|
|
2212
|
-
const previewThreadTs = delivery.usedReplyThreadTs ?? statusThreadTs;
|
|
2213
|
-
const supplementalThreadTs = await delivery.deliverNormally({
|
|
2214
|
-
payload: supplementalPayload,
|
|
2215
|
-
kind: info.kind,
|
|
2216
|
-
forcedThreadTs: previewThreadTs
|
|
2217
|
-
});
|
|
2218
|
-
delivery.markPreviewPayloadDelivered({
|
|
2219
|
-
kind: info.kind,
|
|
2220
|
-
payload,
|
|
2221
|
-
threadTs: supplementalThreadTs
|
|
2222
|
-
});
|
|
2223
|
-
},
|
|
2224
|
-
logPreviewEditFailure: (err) => {
|
|
2225
|
-
logVerbose(`slack: preview final edit failed; falling back to standard send (${formatSlackError(err)})`);
|
|
2226
|
-
}
|
|
2227
|
-
}),
|
|
2228
|
-
deliverNormally: async () => {
|
|
2229
|
-
await delivery.deliverNormally({
|
|
2230
|
-
payload: shouldRestoreTtsSupplementTextForPreviewFallback ? {
|
|
2231
|
-
...payload,
|
|
2232
|
-
text: ttsSupplement?.spokenText
|
|
2233
|
-
} : payload,
|
|
2234
|
-
kind: info.kind
|
|
2235
|
-
});
|
|
2236
|
-
}
|
|
2237
|
-
});
|
|
2238
|
-
};
|
|
2239
|
-
let dispatchError;
|
|
2240
|
-
let queuedFinal = false;
|
|
2241
|
-
let counts = {};
|
|
2242
|
-
try {
|
|
2243
|
-
const turnResult = await dispatchChannelInboundTurn({
|
|
2244
|
-
cfg,
|
|
2245
|
-
channel: "slack",
|
|
2246
|
-
accountId: route.accountId,
|
|
2247
|
-
route: {
|
|
2248
|
-
agentId: route.agentId,
|
|
2249
|
-
sessionKey: route.sessionKey
|
|
2250
|
-
},
|
|
2251
|
-
ctxPayload: prepared.ctxPayload,
|
|
2252
|
-
dispatcherOptions: {
|
|
2253
|
-
...replyPipeline,
|
|
2254
|
-
humanDelay: resolveHumanDelayConfig(cfg, route.agentId)
|
|
2255
|
-
},
|
|
2256
|
-
delivery: {
|
|
2257
|
-
deliver: deliverSlackPayload,
|
|
2258
|
-
onError: onSlackDeliveryError
|
|
2259
|
-
},
|
|
2260
|
-
record: prepared.turn.record,
|
|
2261
|
-
history: prepared.turn.history,
|
|
2262
|
-
botLoopProtection: resolveSlackBotLoopProtection(prepared),
|
|
2263
|
-
replyOptions: {
|
|
2264
|
-
...prepared.turnAdoptionLifecycle ? { turnAdoptionLifecycle: prepared.turnAdoptionLifecycle } : {},
|
|
2265
|
-
skillFilter: prepared.channelConfig?.skills,
|
|
2266
|
-
sourceReplyDeliveryMode,
|
|
2267
|
-
suppressTyping: suppressRoomEventTyping ? true : void 0,
|
|
2268
|
-
hasRepliedRef,
|
|
2269
|
-
disableBlockStreaming,
|
|
2270
|
-
onModelSelected,
|
|
2271
|
-
suppressDefaultToolProgressMessages: progress.suppressDefaultToolProgressMessages ? true : void 0,
|
|
2272
|
-
commentaryProgressEnabled: progress.commentaryProgressEnabled ? true : void 0,
|
|
2273
|
-
progressPreambleEnabled: progress.progressDraftActive && slackStreaming.mode === "progress" ? true : void 0,
|
|
2274
|
-
commentaryPayloadsEnabled: progress.commentaryProgressEnabled ? true : void 0,
|
|
2275
|
-
onVerboseProgressVisibility: progress.commentaryProgressEnabled ? (isActive) => {
|
|
2276
|
-
progress.setShouldYieldDraftProgress(isActive);
|
|
2277
|
-
} : void 0,
|
|
2278
|
-
allowProgressCallbacksWhenSourceDeliverySuppressed: sourceReplyDeliveryMode === "message_tool_only" && statusReactionsEnabled ? true : void 0,
|
|
2279
|
-
allowToolLifecycleWhenProgressHidden: statusReactionsEnabled ? true : void 0,
|
|
2280
|
-
onPartialReply: useStreaming ? void 0 : !previewStreamingEnabled ? void 0 : async (payload) => {
|
|
2281
|
-
progress.updateDraftFromPartial(payload.text);
|
|
2282
|
-
},
|
|
2283
|
-
onAssistantMessageStart: progress.onDraftBoundary,
|
|
2284
|
-
onReasoningEnd: async () => {
|
|
2285
|
-
progress.progressReceipt.closeReasoning();
|
|
2286
|
-
await progress.onDraftBoundary?.();
|
|
2287
|
-
},
|
|
2288
|
-
onQueuedFollowupAdmitted: progress.onQueuedFollowupAdmitted,
|
|
2289
|
-
onReasoningStream: statusReactionsEnabled || progress.previewToolProgressEnabled ? async (payload) => {
|
|
2290
|
-
await progress.pushReasoningProgress(payload);
|
|
2291
|
-
if (!statusReactionsEnabled) return;
|
|
2292
|
-
await statusReactions.setThinking();
|
|
2293
|
-
} : void 0,
|
|
2294
|
-
onToolStart: async (payload) => {
|
|
2295
|
-
if (statusReactionsEnabled) await statusReactions.setTool(payload.name);
|
|
2296
|
-
if (payload.phase === "start") progress.progressReceipt.noteToolCall(payload.name);
|
|
2297
|
-
await progress.pushPreviewProgress(buildChannelProgressDraftLineForEntry(account.config, {
|
|
2298
|
-
event: "tool",
|
|
2299
|
-
itemId: payload.itemId,
|
|
2300
|
-
toolCallId: payload.toolCallId,
|
|
2301
|
-
name: payload.name,
|
|
2302
|
-
phase: payload.phase,
|
|
2303
|
-
args: payload.args
|
|
2304
|
-
}, payload.detailMode ? { detailMode: payload.detailMode } : void 0), { toolName: payload.name });
|
|
2305
|
-
},
|
|
2306
|
-
onItemEvent: async (payload) => {
|
|
2307
|
-
if (progress.streamMode === "status_final" && payload.kind === "preamble") {
|
|
2308
|
-
if (progress.shouldYieldDraftProgress()) return;
|
|
2309
|
-
await progress.progressDraft.pushPreambleHeadline(payload.progressText, { itemId: payload.itemId });
|
|
2310
|
-
if (progress.commentaryProgressEnabled) {
|
|
2311
|
-
if (await progress.progressDraft.pushCommentaryProgress(payload.progressText, { itemId: payload.itemId })) progress.progressReceipt.noteCommentary(payload.itemId, payload.progressText);
|
|
2312
|
-
}
|
|
2313
|
-
return;
|
|
2314
|
-
}
|
|
2315
|
-
await progress.pushPreviewProgress(buildChannelProgressDraftLineForEntry(account.config, {
|
|
2316
|
-
event: "item",
|
|
2317
|
-
itemId: payload.itemId,
|
|
2318
|
-
toolCallId: payload.toolCallId,
|
|
2319
|
-
itemKind: payload.kind,
|
|
2320
|
-
title: payload.title,
|
|
2321
|
-
name: payload.name,
|
|
2322
|
-
phase: payload.phase,
|
|
2323
|
-
status: payload.status,
|
|
2324
|
-
summary: payload.summary,
|
|
2325
|
-
progressText: payload.progressText,
|
|
2326
|
-
meta: payload.meta
|
|
2327
|
-
}));
|
|
2328
|
-
},
|
|
2329
|
-
onPlanUpdate: async (payload) => {
|
|
2330
|
-
if (payload.phase !== "update") return;
|
|
2331
|
-
await progress.pushPlanProgress(payload.steps, payload.explanation);
|
|
2332
|
-
},
|
|
2333
|
-
onApprovalEvent: async (payload) => {
|
|
2334
|
-
if (payload.phase !== "requested") return;
|
|
2335
|
-
await progress.pushPreviewProgress(buildChannelProgressDraftLine({
|
|
2336
|
-
event: "approval",
|
|
2337
|
-
phase: payload.phase,
|
|
2338
|
-
title: payload.title,
|
|
2339
|
-
command: payload.command,
|
|
2340
|
-
reason: payload.reason,
|
|
2341
|
-
message: payload.message
|
|
2342
|
-
}));
|
|
2343
|
-
},
|
|
2344
|
-
onCommandOutput: async (payload) => {
|
|
2345
|
-
if (payload.phase !== "end") return;
|
|
2346
|
-
await progress.pushPreviewProgress(buildChannelProgressDraftLine({
|
|
2347
|
-
event: "command-output",
|
|
2348
|
-
itemId: payload.itemId,
|
|
2349
|
-
toolCallId: payload.toolCallId,
|
|
2350
|
-
phase: payload.phase,
|
|
2351
|
-
title: payload.title,
|
|
2352
|
-
name: payload.name,
|
|
2353
|
-
status: payload.status,
|
|
2354
|
-
exitCode: payload.exitCode
|
|
2355
|
-
}));
|
|
2356
|
-
},
|
|
2357
|
-
onPatchSummary: async (payload) => {
|
|
2358
|
-
if (payload.phase !== "end") return;
|
|
2359
|
-
await progress.pushPreviewProgress(buildChannelProgressDraftLine({
|
|
2360
|
-
event: "patch",
|
|
2361
|
-
itemId: payload.itemId,
|
|
2362
|
-
toolCallId: payload.toolCallId,
|
|
2363
|
-
phase: payload.phase,
|
|
2364
|
-
title: payload.title,
|
|
2365
|
-
name: payload.name,
|
|
2366
|
-
added: payload.added,
|
|
2367
|
-
modified: payload.modified,
|
|
2368
|
-
deleted: payload.deleted,
|
|
2369
|
-
summary: payload.summary
|
|
2370
|
-
}));
|
|
2371
|
-
}
|
|
2372
|
-
}
|
|
2373
|
-
});
|
|
2374
|
-
if (turnResult.dispatched) {
|
|
2375
|
-
const result = turnResult.dispatchResult;
|
|
2376
|
-
queuedFinal = result.queuedFinal;
|
|
2377
|
-
counts = result.counts;
|
|
2378
|
-
}
|
|
2379
|
-
} catch (err) {
|
|
2380
|
-
dispatchError = err;
|
|
2381
|
-
} finally {
|
|
2382
|
-
progress.progressDraft.cancel();
|
|
2383
|
-
await draftStream?.discardPending();
|
|
2384
|
-
}
|
|
2385
|
-
let streamFallbackDelivered = false;
|
|
2386
|
-
const finalStream = delivery.streamSession;
|
|
2387
|
-
if (finalStream && !finalStream.stopped) try {
|
|
2388
|
-
const completionChunks = progress.useNativeProgressStreaming && !progress.nativeProgressCompletionSent ? progress.buildNativeProgressCompletionChunks(dispatchError ? "error" : progress.nativeProgressTerminalStatus) : void 0;
|
|
2389
|
-
if (completionChunks?.length) progress.nativeProgressCompletionSent = true;
|
|
2390
|
-
const stopResult = await stopSlackStream({
|
|
2391
|
-
session: finalStream,
|
|
2392
|
-
...completionChunks?.length ? { chunks: completionChunks } : {},
|
|
2393
|
-
...slackMessageMetadata ? { metadata: slackMessageMetadata } : {}
|
|
2394
|
-
});
|
|
2395
|
-
delivery.acknowledgeStoppedStreamedDeliveries(finalStream, stopResult?.messageId);
|
|
2396
|
-
if (progress.pendingNativeProgressReceipt && stopResult?.messageId && !progress.progressReceiptCollapsed) await progress.collapseProgressReceipt({
|
|
2397
|
-
channelId: finalStream.channel,
|
|
2398
|
-
messageId: stopResult.messageId,
|
|
2399
|
-
text: progress.pendingNativeProgressReceipt,
|
|
2400
|
-
threadTs: finalStream.threadTs
|
|
2401
|
-
});
|
|
2402
|
-
} catch (err) {
|
|
2403
|
-
if (err instanceof SlackStreamNotDeliveredError) {
|
|
2404
|
-
streamFallbackDelivered = await delivery.deliverPendingStreamFallback(finalStream, err);
|
|
2405
|
-
if (!streamFallbackDelivered) dispatchError ??= err;
|
|
2406
|
-
} else {
|
|
2407
|
-
const error = formatSlackError(err);
|
|
2408
|
-
delivery.emitAcknowledgedStreamedDeliveries();
|
|
2409
|
-
delivery.emitFailedPendingStreamedDeliveries(error);
|
|
2410
|
-
runtime.error?.(danger(`slack-stream: failed to stop stream: ${error}`));
|
|
2411
|
-
if (!finalStream.delivered) dispatchError ??= err;
|
|
2412
|
-
}
|
|
2413
|
-
}
|
|
2414
|
-
counts = delivery.reconcileCounts(counts);
|
|
2415
|
-
queuedFinal = queuedFinal && (counts.final ?? 0) > 0;
|
|
2416
|
-
const anyReplyDelivered = hasVisibleInboundReplyDispatch({
|
|
2417
|
-
queuedFinal,
|
|
2418
|
-
counts
|
|
2419
|
-
}, {
|
|
2420
|
-
observedReplyDelivery: delivery.observedReplyDelivery,
|
|
2421
|
-
fallbackDelivered: streamFallbackDelivered
|
|
2422
|
-
});
|
|
2423
|
-
if (statusReactionsEnabled) if (dispatchError) await statusReactions.setError();
|
|
2424
|
-
else if (anyReplyDelivered) {
|
|
2425
|
-
await statusReactions.setDone();
|
|
2426
|
-
statusReactions.restoreInitial();
|
|
2427
|
-
} else await statusReactions.restoreInitial();
|
|
2428
|
-
const participationThreadTs = delivery.usedReplyThreadTs ?? statusThreadTs;
|
|
2429
|
-
if (anyReplyDelivered && participationThreadTs) recordSlackThreadParticipation(account.accountId, message.channel, participationThreadTs, {
|
|
2430
|
-
agentId: route.agentId,
|
|
2431
|
-
...prepared.eventScope ? { teamId: prepared.eventScope.teamId } : {}
|
|
2432
|
-
});
|
|
2433
|
-
if (dispatchError) throw toErrorObject(dispatchError, "Slack dispatch failed");
|
|
2434
|
-
if (!anyReplyDelivered && !draftPreviewCommitted.value) {
|
|
2435
|
-
await draftStream?.clear();
|
|
2436
|
-
return;
|
|
2437
|
-
}
|
|
2438
|
-
if (shouldLogVerbose()) {
|
|
2439
|
-
const finalCount = counts.final;
|
|
2440
|
-
logVerbose(`slack: delivered ${finalCount} reply${finalCount === 1 ? "" : "ies"} to ${prepared.replyTarget}`);
|
|
2441
|
-
}
|
|
2442
|
-
}
|
|
2443
|
-
//#endregion
|
|
2444
|
-
//#region extensions/slack/src/agent-context.ts
|
|
2445
|
-
function asRecord(value) {
|
|
2446
|
-
return value && typeof value === "object" && !Array.isArray(value) ? value : void 0;
|
|
2447
|
-
}
|
|
2448
|
-
function trimmedString(value) {
|
|
2449
|
-
return typeof value === "string" && value.trim() ? value.trim() : void 0;
|
|
2450
|
-
}
|
|
2451
|
-
function normalizeEntity(value) {
|
|
2452
|
-
const entity = asRecord(value);
|
|
2453
|
-
const type = trimmedString(entity?.type);
|
|
2454
|
-
if (!entity || !type) return;
|
|
2455
|
-
const teamId = trimmedString(entity.team_id);
|
|
2456
|
-
if (type === "slack#/types/channel_id" || type === "slack#/types/canvas_id" || type === "slack#/types/list_id") {
|
|
2457
|
-
const entityValue = trimmedString(entity.value);
|
|
2458
|
-
return entityValue ? {
|
|
2459
|
-
type,
|
|
2460
|
-
value: entityValue,
|
|
2461
|
-
...teamId ? { team_id: teamId } : {}
|
|
2462
|
-
} : void 0;
|
|
2463
|
-
}
|
|
2464
|
-
if (type !== "slack#/types/message_context") return;
|
|
2465
|
-
const message = asRecord(entity.value);
|
|
2466
|
-
const channelId = trimmedString(message?.channel_id);
|
|
2467
|
-
const messageTs = trimmedString(message?.message_ts);
|
|
2468
|
-
return channelId && messageTs ? {
|
|
2469
|
-
type,
|
|
2470
|
-
value: {
|
|
2471
|
-
channel_id: channelId,
|
|
2472
|
-
message_ts: messageTs
|
|
2473
|
-
},
|
|
2474
|
-
...teamId ? { team_id: teamId } : {}
|
|
2475
|
-
} : void 0;
|
|
2476
|
-
}
|
|
2477
|
-
function isSlackAppContext(value) {
|
|
2478
|
-
return Boolean(asRecord(value));
|
|
2479
|
-
}
|
|
2480
|
-
function normalizeSlackAppContextEntities(value) {
|
|
2481
|
-
const context = asRecord(value);
|
|
2482
|
-
if (!Array.isArray(context?.entities)) return [];
|
|
2483
|
-
return context.entities.flatMap((entity) => {
|
|
2484
|
-
const normalized = normalizeEntity(entity);
|
|
2485
|
-
return normalized ? [normalized] : [];
|
|
2486
|
-
});
|
|
2487
|
-
}
|
|
2488
|
-
//#endregion
|
|
2489
|
-
//#region extensions/slack/src/monitor/message-handler/preflight-audio.ts
|
|
2490
|
-
const SLACK_DEFAULT_ECHO_TRANSCRIPT_FORMAT = "📝 \"{transcript}\"";
|
|
2491
|
-
const loadSlackPreflightAudioRuntime = createLazyRuntimeModule(() => import("./preflight-audio.runtime-D5Bgags0.js"));
|
|
2492
|
-
function isSlackAudioFile(file) {
|
|
2493
|
-
if (file.subtype === "slack_audio") return true;
|
|
2494
|
-
if ((file.mimetype?.split(";")[0]?.trim().toLowerCase())?.startsWith("audio/")) return true;
|
|
2495
|
-
return Boolean(mimeTypeFromFilePath(file.name)?.startsWith("audio/"));
|
|
2496
|
-
}
|
|
2497
|
-
function findCaptionlessSlackAudioFile(message) {
|
|
2498
|
-
if (message.text?.trim()) return;
|
|
2499
|
-
return message.files?.slice(0, 8).find(isSlackAudioFile);
|
|
2500
|
-
}
|
|
2501
|
-
function formatSlackAudioTranscriptForAgent(params) {
|
|
2502
|
-
return [`[Audio transcript (machine-generated, untrusted)]: ${JSON.stringify(params.transcript)}`, params.rawBody].filter(Boolean).join("\n");
|
|
2503
|
-
}
|
|
2504
|
-
function suppressSlackPreflightAudioEcho(cfg) {
|
|
2505
|
-
const audio = cfg.tools?.media?.audio;
|
|
2506
|
-
if (!audio?.echoTranscript) return cfg;
|
|
2507
|
-
return {
|
|
2508
|
-
...cfg,
|
|
2509
|
-
tools: {
|
|
2510
|
-
...cfg.tools,
|
|
2511
|
-
media: {
|
|
2512
|
-
...cfg.tools?.media,
|
|
2513
|
-
audio: {
|
|
2514
|
-
...audio,
|
|
2515
|
-
echoTranscript: false
|
|
2516
|
-
}
|
|
2517
|
-
}
|
|
2518
|
-
}
|
|
2519
|
-
};
|
|
2520
|
-
}
|
|
2521
|
-
async function resolveSlackPreflightAudioTranscript(params) {
|
|
2522
|
-
const mediaIndex = params.media.findIndex((entry) => entry.contentType?.toLowerCase().startsWith("audio/"));
|
|
2523
|
-
if (mediaIndex < 0) return null;
|
|
2524
|
-
try {
|
|
2525
|
-
const { transcribeFirstAudio } = await loadSlackPreflightAudioRuntime();
|
|
2526
|
-
const transcript = await transcribeFirstAudio({
|
|
2527
|
-
ctx: {
|
|
2528
|
-
media: [...params.media],
|
|
2529
|
-
Provider: "slack",
|
|
2530
|
-
Surface: "slack",
|
|
2531
|
-
OriginatingChannel: "slack",
|
|
2532
|
-
OriginatingTo: params.originatingTo,
|
|
2533
|
-
AccountId: params.accountId,
|
|
2534
|
-
MessageThreadId: params.messageThreadId,
|
|
2535
|
-
ChatType: "channel",
|
|
2536
|
-
SessionKey: params.sessionKey
|
|
2537
|
-
},
|
|
2538
|
-
cfg: suppressSlackPreflightAudioEcho(params.cfg)
|
|
2539
|
-
});
|
|
2540
|
-
return transcript ? {
|
|
2541
|
-
transcript,
|
|
2542
|
-
mediaIndex
|
|
2543
|
-
} : null;
|
|
2544
|
-
} catch (err) {
|
|
2545
|
-
logVerbose(`slack: audio preflight transcription failed: ${String(err)}`);
|
|
2546
|
-
return null;
|
|
2547
|
-
}
|
|
2548
|
-
}
|
|
2549
|
-
function formatSlackAudioTranscriptEcho(transcript, format) {
|
|
2550
|
-
return format.replace("{transcript}", () => transcript);
|
|
2551
|
-
}
|
|
2552
|
-
async function sendSlackPreflightAudioTranscriptEcho(params) {
|
|
2553
|
-
const audio = params.cfg.tools?.media?.audio;
|
|
2554
|
-
if (!audio?.echoTranscript) return;
|
|
2555
|
-
const text = formatSlackAudioTranscriptEcho(params.transcript, audio.echoFormat ?? SLACK_DEFAULT_ECHO_TRANSCRIPT_FORMAT);
|
|
2556
|
-
try {
|
|
2557
|
-
const { sendDurableMessageBatch } = await loadSlackPreflightAudioRuntime();
|
|
2558
|
-
const send = await sendDurableMessageBatch({
|
|
2559
|
-
cfg: params.cfg,
|
|
2560
|
-
channel: "slack",
|
|
2561
|
-
to: params.originatingTo,
|
|
2562
|
-
accountId: params.accountId,
|
|
2563
|
-
threadId: params.messageThreadId,
|
|
2564
|
-
payloads: [{ text }],
|
|
2565
|
-
bestEffort: true,
|
|
2566
|
-
durability: "best_effort"
|
|
2567
|
-
});
|
|
2568
|
-
if (send.status === "failed") throw send.error;
|
|
2569
|
-
} catch (err) {
|
|
2570
|
-
logVerbose(`slack: audio transcript echo failed: ${String(err)}`);
|
|
2571
|
-
}
|
|
2572
|
-
}
|
|
2573
|
-
async function discardSlackPreflightMedia(media) {
|
|
2574
|
-
await Promise.allSettled((media ?? []).map((entry) => fs.rm(entry.path, { force: true })));
|
|
2575
|
-
}
|
|
2576
|
-
//#endregion
|
|
2577
|
-
//#region extensions/slack/src/monitor/message-handler/prepare-content.ts
|
|
2578
|
-
const SLACK_MENTION_RESOLUTION_CONCURRENCY = 4;
|
|
2579
|
-
const SLACK_MENTION_RESOLUTION_MAX_LOOKUPS_PER_MESSAGE = 20;
|
|
2580
|
-
const SLACK_USER_MENTION_RE$1 = /<@([A-Z0-9]+)(?:\|[^>]+)?>/gi;
|
|
2581
|
-
const loadSlackMediaModule$1 = createLazyRuntimeModule(() => import("./actions-D3NuJvva.js").then((n) => n.g));
|
|
2582
|
-
function collectUniqueSlackMentionIds$1(texts) {
|
|
2583
|
-
const seen = /* @__PURE__ */ new Set();
|
|
2584
|
-
const mentionIds = [];
|
|
2585
|
-
for (const text of texts) {
|
|
2586
|
-
if (!text) continue;
|
|
2587
|
-
SLACK_USER_MENTION_RE$1.lastIndex = 0;
|
|
2588
|
-
for (const match of text.matchAll(SLACK_USER_MENTION_RE$1)) {
|
|
2589
|
-
const userId = match[1];
|
|
2590
|
-
if (!userId || seen.has(userId)) continue;
|
|
2591
|
-
seen.add(userId);
|
|
2592
|
-
mentionIds.push(userId);
|
|
2593
|
-
}
|
|
2594
|
-
}
|
|
2595
|
-
return mentionIds;
|
|
2596
|
-
}
|
|
2597
|
-
function renderSlackUserMentions(text, renderedMentions) {
|
|
2598
|
-
if (!text || renderedMentions.size === 0) return text;
|
|
2599
|
-
SLACK_USER_MENTION_RE$1.lastIndex = 0;
|
|
2600
|
-
return text.replace(SLACK_USER_MENTION_RE$1, (full, userId) => {
|
|
2601
|
-
return renderedMentions.get(userId) ?? full;
|
|
2602
|
-
});
|
|
2603
|
-
}
|
|
2604
|
-
function filterInheritedParentFiles(params) {
|
|
2605
|
-
const { files, isThreadReply, threadStarter } = params;
|
|
2606
|
-
if (!isThreadReply || !files?.length) return files;
|
|
2607
|
-
if (!threadStarter?.files?.length) return files;
|
|
2608
|
-
const starterFileIds = new Set(threadStarter.files.map((file) => file.id));
|
|
2609
|
-
const filtered = files.filter((file) => !file.id || !starterFileIds.has(file.id));
|
|
2610
|
-
if (filtered.length < files.length) logVerbose(`slack: filtered ${files.length - filtered.length} inherited parent file(s) from thread reply`);
|
|
2611
|
-
return filtered.length > 0 ? filtered : void 0;
|
|
2612
|
-
}
|
|
2613
|
-
async function resolveSlackMessageContent(params) {
|
|
2614
|
-
const ownFiles = filterInheritedParentFiles({
|
|
2615
|
-
files: params.message.files,
|
|
2616
|
-
isThreadReply: params.isThreadReply,
|
|
2617
|
-
threadStarter: params.threadStarter
|
|
2618
|
-
});
|
|
2619
|
-
const mediaPromise = ownFiles && ownFiles.length > 0 ? loadSlackMediaModule$1().then(({ resolveSlackMedia }) => resolveSlackMedia({
|
|
2620
|
-
files: ownFiles,
|
|
2621
|
-
client: params.client,
|
|
2622
|
-
token: params.botToken,
|
|
2623
|
-
maxBytes: params.mediaMaxBytes,
|
|
2624
|
-
readIdleTimeoutMs: params.mediaReadIdleTimeoutMs,
|
|
2625
|
-
totalTimeoutMs: params.mediaTotalTimeoutMs,
|
|
2626
|
-
abortSignal: params.abortSignal,
|
|
2627
|
-
preloadedMedia: params.preloadedMedia
|
|
2628
|
-
})) : Promise.resolve(null);
|
|
2629
|
-
const attachmentContentPromise = params.message.attachments && params.message.attachments.length > 0 ? loadSlackMediaModule$1().then(({ resolveSlackAttachmentContent }) => resolveSlackAttachmentContent({
|
|
2630
|
-
attachments: params.message.attachments,
|
|
2631
|
-
client: params.client,
|
|
2632
|
-
token: params.botToken,
|
|
2633
|
-
maxBytes: params.mediaMaxBytes,
|
|
2634
|
-
readIdleTimeoutMs: params.mediaReadIdleTimeoutMs,
|
|
2635
|
-
totalTimeoutMs: params.mediaTotalTimeoutMs,
|
|
2636
|
-
abortSignal: params.abortSignal
|
|
2637
|
-
})) : Promise.resolve(null);
|
|
2638
|
-
const [media, attachmentContent] = await Promise.all([mediaPromise, attachmentContentPromise]);
|
|
2639
|
-
const mergedMedia = [...media ?? [], ...attachmentContent?.media ?? []];
|
|
2640
|
-
const effectiveDirectMedia = mergedMedia.length > 0 ? mergedMedia : null;
|
|
2641
|
-
const mediaPlaceholder = effectiveDirectMedia ? effectiveDirectMedia.map((item) => item.placeholder).join(" ") : void 0;
|
|
2642
|
-
const fallbackFiles = ownFiles ?? [];
|
|
2643
|
-
const fileOnlyFallback = !mediaPlaceholder && fallbackFiles.length > 0 ? fallbackFiles.slice(0, 8).map((file) => formatSlackFileReference(file)).join(", ") : void 0;
|
|
2644
|
-
const fileOnlyPlaceholder = fileOnlyFallback ? `[Slack file: ${fileOnlyFallback}]` : void 0;
|
|
2645
|
-
let botAttachmentText;
|
|
2646
|
-
if (params.isBotMessage && !attachmentContent?.text) {
|
|
2647
|
-
const botAttachmentTextParts = [];
|
|
2648
|
-
for (const attachment of params.message.attachments ?? []) {
|
|
2649
|
-
const text = normalizeOptionalString(attachment.text) ?? normalizeOptionalString(attachment.fallback);
|
|
2650
|
-
if (text) botAttachmentTextParts.push(text);
|
|
2651
|
-
}
|
|
2652
|
-
botAttachmentText = botAttachmentTextParts.length > 0 ? botAttachmentTextParts.join("\n") : void 0;
|
|
2653
|
-
}
|
|
2654
|
-
const textParts = [
|
|
2655
|
-
resolveSlackMessageText(params.message),
|
|
2656
|
-
attachmentContent?.text,
|
|
2657
|
-
botAttachmentText
|
|
2658
|
-
];
|
|
2659
|
-
const renderedMentions = /* @__PURE__ */ new Map();
|
|
2660
|
-
const resolveUserName = params.resolveUserName;
|
|
2661
|
-
if (resolveUserName) {
|
|
2662
|
-
const mentionIds = collectUniqueSlackMentionIds$1(textParts);
|
|
2663
|
-
const lookupIds = mentionIds.slice(0, SLACK_MENTION_RESOLUTION_MAX_LOOKUPS_PER_MESSAGE);
|
|
2664
|
-
const skippedLookups = mentionIds.length - lookupIds.length;
|
|
2665
|
-
if (skippedLookups > 0) logVerbose(`slack: skipping ${skippedLookups} mention lookup(s) beyond per-message cap (${SLACK_MENTION_RESOLUTION_MAX_LOOKUPS_PER_MESSAGE})`);
|
|
2666
|
-
const { results } = await runTasksWithConcurrency({
|
|
2667
|
-
tasks: lookupIds.map((userId) => async () => {
|
|
2668
|
-
const renderedName = normalizeOptionalString((await resolveUserName(userId))?.name);
|
|
2669
|
-
return {
|
|
2670
|
-
userId,
|
|
2671
|
-
rendered: renderedName ? `<@${userId}> (${renderedName})` : null
|
|
2672
|
-
};
|
|
2673
|
-
}),
|
|
2674
|
-
limit: SLACK_MENTION_RESOLUTION_CONCURRENCY
|
|
2675
|
-
});
|
|
2676
|
-
for (const result of results) {
|
|
2677
|
-
if (!result) continue;
|
|
2678
|
-
renderedMentions.set(result.userId, result.rendered);
|
|
2679
|
-
}
|
|
2680
|
-
}
|
|
2681
|
-
const rawBody = [
|
|
2682
|
-
renderSlackUserMentions(textParts[0], renderedMentions),
|
|
2683
|
-
renderSlackUserMentions(textParts[1], renderedMentions),
|
|
2684
|
-
renderSlackUserMentions(textParts[2], renderedMentions),
|
|
2685
|
-
mediaPlaceholder,
|
|
2686
|
-
fileOnlyPlaceholder
|
|
2687
|
-
].filter(Boolean).join("\n") || "";
|
|
2688
|
-
if (!rawBody) return null;
|
|
2689
|
-
return {
|
|
2690
|
-
rawBody,
|
|
2691
|
-
effectiveDirectMedia
|
|
2692
|
-
};
|
|
2693
|
-
}
|
|
2694
|
-
//#endregion
|
|
2695
|
-
//#region extensions/slack/src/monitor/message-handler/prepare-dm-history.ts
|
|
2696
|
-
function resolveSlackDmHistoryLimit(params) {
|
|
2697
|
-
const override = params.userId && params.account.config.dms?.[params.userId]?.historyLimit !== void 0 ? params.account.config.dms[params.userId]?.historyLimit : void 0;
|
|
2698
|
-
return Math.max(0, override ?? params.defaultLimit);
|
|
2699
|
-
}
|
|
2700
|
-
async function resolveSlackDmHistoryContext(params) {
|
|
2701
|
-
const maxMessages = Math.max(0, Math.floor(params.limit));
|
|
2702
|
-
if (maxMessages <= 0) return {
|
|
2703
|
-
body: void 0,
|
|
2704
|
-
inboundHistory: void 0
|
|
2705
|
-
};
|
|
2706
|
-
try {
|
|
2707
|
-
const messages = ((await (params.eventScope?.client ?? params.ctx.app.client).conversations.history({
|
|
2708
|
-
token: params.ctx.botToken,
|
|
2709
|
-
channel: params.channelId,
|
|
2710
|
-
...params.currentMessageTs ? {
|
|
2711
|
-
latest: params.currentMessageTs,
|
|
2712
|
-
inclusive: true
|
|
2713
|
-
} : {},
|
|
2714
|
-
limit: maxMessages + 1
|
|
2715
|
-
})).messages ?? []).filter((message) => {
|
|
2716
|
-
if (params.currentMessageTs && message.ts === params.currentMessageTs) return false;
|
|
2717
|
-
return Boolean(normalizeOptionalString(message.text));
|
|
2718
|
-
}).slice(0, maxMessages).toReversed();
|
|
2719
|
-
if (messages.length === 0) return {
|
|
2720
|
-
body: void 0,
|
|
2721
|
-
inboundHistory: void 0
|
|
2722
|
-
};
|
|
2723
|
-
const userNames = /* @__PURE__ */ new Map();
|
|
2724
|
-
const resolveUserLabel = async (userId) => {
|
|
2725
|
-
const cached = userNames.get(userId);
|
|
2726
|
-
if (cached) return cached;
|
|
2727
|
-
const label = normalizeOptionalString((await params.ctx.resolveUserName(userId, params.eventScope)).name) ?? userId;
|
|
2728
|
-
userNames.set(userId, label);
|
|
2729
|
-
return label;
|
|
2730
|
-
};
|
|
2731
|
-
const entries = [];
|
|
2732
|
-
const formatted = [];
|
|
2733
|
-
for (const message of messages) {
|
|
2734
|
-
const body = normalizeOptionalString(message.text);
|
|
2735
|
-
if (!body) continue;
|
|
2736
|
-
const isCurrentBot = params.ctx.botUserId && message.user === params.ctx.botUserId || params.ctx.botId && message.bot_id === params.ctx.botId;
|
|
2737
|
-
const role = isCurrentBot || message.bot_id ? "assistant" : "user";
|
|
2738
|
-
const sender = `${isCurrentBot ? "Assistant" : message.user ? await resolveUserLabel(message.user) : normalizeOptionalString(message.username) ?? (message.bot_id ? "Bot" : "Unknown")} (${role})`;
|
|
2739
|
-
const timestamp = resolveSlackTimestampMs(message.ts);
|
|
2740
|
-
entries.push({
|
|
2741
|
-
sender,
|
|
2742
|
-
body,
|
|
2743
|
-
timestamp
|
|
2744
|
-
});
|
|
2745
|
-
formatted.push(formatInboundEnvelope({
|
|
2746
|
-
channel: "Slack",
|
|
2747
|
-
from: sender,
|
|
2748
|
-
timestamp,
|
|
2749
|
-
body: `${body}\n[slack message id: ${message.ts ?? "unknown"} channel: ${params.channelId}]`,
|
|
2750
|
-
chatType: "direct",
|
|
2751
|
-
envelope: params.envelopeOptions
|
|
2752
|
-
}));
|
|
2753
|
-
}
|
|
2754
|
-
return {
|
|
2755
|
-
body: formatted.length > 0 ? formatted.join("\n\n") : void 0,
|
|
2756
|
-
inboundHistory: entries.length > 0 ? entries : void 0
|
|
2757
|
-
};
|
|
2758
|
-
} catch (err) {
|
|
2759
|
-
logVerbose(`slack: failed to fetch DM history for channel ${params.channelId}: ${formatErrorMessage(err)}`);
|
|
2760
|
-
return {
|
|
2761
|
-
body: void 0,
|
|
2762
|
-
inboundHistory: void 0
|
|
2763
|
-
};
|
|
2764
|
-
}
|
|
2765
|
-
}
|
|
2766
|
-
//#endregion
|
|
2767
|
-
//#region extensions/slack/src/monitor/message-handler/prepare-routing.ts
|
|
2768
|
-
const slackRouteBindingConfigCache = /* @__PURE__ */ new WeakMap();
|
|
2769
|
-
function slackTargetDefaultKindForPeer(kind) {
|
|
2770
|
-
return kind === "direct" ? "user" : "channel";
|
|
2771
|
-
}
|
|
2772
|
-
function slackTargetKindMatchesPeer(peerKind, targetKind) {
|
|
2773
|
-
if (targetKind === "user") return peerKind === "direct";
|
|
2774
|
-
return peerKind === "channel" || peerKind === "group";
|
|
2775
|
-
}
|
|
2776
|
-
function normalizeSlackRouteBindingPeer(peer) {
|
|
2777
|
-
const rawId = peer.id.trim();
|
|
2778
|
-
if (!rawId || rawId === "*") return peer;
|
|
2779
|
-
const target = (() => {
|
|
2780
|
-
try {
|
|
2781
|
-
return parseSlackTarget(rawId, { defaultKind: slackTargetDefaultKindForPeer(peer.kind) });
|
|
2782
|
-
} catch {
|
|
2783
|
-
return;
|
|
2784
|
-
}
|
|
2785
|
-
})();
|
|
2786
|
-
if (!target || !slackTargetKindMatchesPeer(peer.kind, target.kind) || target.id === peer.id) return peer;
|
|
2787
|
-
return {
|
|
2788
|
-
...peer,
|
|
2789
|
-
id: target.id
|
|
2790
|
-
};
|
|
2791
|
-
}
|
|
2792
|
-
function normalizeSlackRouteBindingConfig(cfg) {
|
|
2793
|
-
const bindings = cfg.bindings;
|
|
2794
|
-
const cached = slackRouteBindingConfigCache.get(cfg);
|
|
2795
|
-
if (cached && cached.bindingsRef === bindings) return cached.normalizedCfg;
|
|
2796
|
-
if (!Array.isArray(bindings)) return cfg;
|
|
2797
|
-
let changed = false;
|
|
2798
|
-
const normalizedBindings = bindings.map((binding) => {
|
|
2799
|
-
if (binding.type === "acp" || binding.match.channel.trim().toLowerCase() !== "slack") return binding;
|
|
2800
|
-
const peer = binding.match.peer;
|
|
2801
|
-
if (!peer) return binding;
|
|
2802
|
-
const normalizedPeer = normalizeSlackRouteBindingPeer(peer);
|
|
2803
|
-
if (normalizedPeer === peer) return binding;
|
|
2804
|
-
changed = true;
|
|
2805
|
-
return {
|
|
2806
|
-
...binding,
|
|
2807
|
-
match: {
|
|
2808
|
-
...binding.match,
|
|
2809
|
-
peer: normalizedPeer
|
|
2810
|
-
}
|
|
2811
|
-
};
|
|
2812
|
-
});
|
|
2813
|
-
const normalizedCfg = changed ? {
|
|
2814
|
-
...cfg,
|
|
2815
|
-
bindings: normalizedBindings
|
|
2816
|
-
} : cfg;
|
|
2817
|
-
slackRouteBindingConfigCache.set(cfg, {
|
|
2818
|
-
bindingsRef: bindings,
|
|
2819
|
-
normalizedCfg
|
|
2820
|
-
});
|
|
2821
|
-
return normalizedCfg;
|
|
2822
|
-
}
|
|
2823
|
-
function resolveSlackBaseConversationId(params) {
|
|
2824
|
-
const raw = params.isDirectMessage ? `user:${params.message.user ?? "unknown"}` : params.message.channel;
|
|
2825
|
-
return params.eventScope ? `team:${encodeURIComponent(params.eventScope.teamId)}:${raw}` : raw;
|
|
2826
|
-
}
|
|
2827
|
-
function qualifySlackPeerId(params) {
|
|
2828
|
-
if (!params.eventScope) return params.id;
|
|
2829
|
-
return `team:${encodeURIComponent(params.eventScope.teamId)}:${params.kind}:${encodeURIComponent(params.id)}`;
|
|
2830
|
-
}
|
|
2831
|
-
function resolveSlackInitialAgentRoute(params) {
|
|
2832
|
-
const route = resolveAgentRoute({
|
|
2833
|
-
cfg: normalizeSlackRouteBindingConfig(params.ctx.cfg),
|
|
2834
|
-
channel: "slack",
|
|
2835
|
-
accountId: params.account.accountId,
|
|
2836
|
-
teamId: params.eventScope?.teamId || params.ctx.teamId || void 0,
|
|
2837
|
-
peer: {
|
|
2838
|
-
kind: params.isDirectMessage ? "direct" : params.isRoom ? "channel" : "group",
|
|
2839
|
-
id: qualifySlackPeerId({
|
|
2840
|
-
id: params.isDirectMessage ? params.message.user ?? "unknown" : params.message.channel,
|
|
2841
|
-
kind: params.isDirectMessage ? "user" : "channel",
|
|
2842
|
-
eventScope: params.eventScope
|
|
2843
|
-
})
|
|
2844
|
-
}
|
|
2845
|
-
});
|
|
2846
|
-
if (!params.eventScope || !params.isDirectMessage || route.dmScope !== "main") return route;
|
|
2847
|
-
const partition = `account:${encodeURIComponent(params.account.accountId).toLowerCase()}:team:${encodeURIComponent(params.eventScope.teamId).toLowerCase()}`;
|
|
2848
|
-
const sessionKey = `${route.sessionKey}:${partition}`;
|
|
2849
|
-
return {
|
|
2850
|
-
...route,
|
|
2851
|
-
sessionKey,
|
|
2852
|
-
mainSessionKey: sessionKey
|
|
2853
|
-
};
|
|
2854
|
-
}
|
|
2855
|
-
function resolveSlackRoutingContext(params) {
|
|
2856
|
-
const { ctx, account, message, isDirectMessage, isGroupDm, isRoom, isRoomish, channelConfig, seedTopLevelRoomThread, assistantThreadTs, agentViewThreadTs, eventScope } = params;
|
|
2857
|
-
let route = resolveSlackInitialAgentRoute({
|
|
2858
|
-
ctx,
|
|
2859
|
-
account,
|
|
2860
|
-
message,
|
|
2861
|
-
isDirectMessage,
|
|
2862
|
-
isRoom,
|
|
2863
|
-
eventScope
|
|
2864
|
-
});
|
|
2865
|
-
const chatType = isDirectMessage ? "direct" : isGroupDm ? "group" : "channel";
|
|
2866
|
-
const replyToMode = channelConfig?.replyToMode ?? resolveSlackReplyToMode(account, chatType);
|
|
2867
|
-
const threadContext = resolveSlackThreadContext({
|
|
2868
|
-
message,
|
|
2869
|
-
replyToMode,
|
|
2870
|
-
isDirectMessage
|
|
2871
|
-
});
|
|
2872
|
-
const threadTs = threadContext.incomingThreadTs;
|
|
2873
|
-
const isThreadReply = threadContext.isThreadReply;
|
|
2874
|
-
const autoThreadId = !isThreadReply && replyToMode === "all" && threadContext.messageTs ? threadContext.messageTs : void 0;
|
|
2875
|
-
const seedCandidateThreadId = threadContext.incomingThreadTs ?? threadContext.messageTs;
|
|
2876
|
-
const routedThreadId = (isDirectMessage ? assistantThreadTs ?? agentViewThreadTs : isRoomish ? isThreadReply && threadTs ? threadTs : void 0 : isThreadReply ? threadTs : autoThreadId) ?? (isRoomish ? !isThreadReply && isRoom && seedTopLevelRoomThread && replyToMode !== "off" && seedCandidateThreadId ? seedCandidateThreadId : void 0 : void 0);
|
|
2877
|
-
const baseConversationId = resolveSlackBaseConversationId({
|
|
2878
|
-
message,
|
|
2879
|
-
isDirectMessage,
|
|
2880
|
-
eventScope
|
|
2881
|
-
});
|
|
2882
|
-
const runtimeBindingThreadId = routedThreadId ?? (isDirectMessage && isThreadReply ? threadTs : void 0);
|
|
2883
|
-
const boundThreadRoute = !eventScope && runtimeBindingThreadId ? resolveRuntimeConversationBindingRoute({
|
|
2884
|
-
route,
|
|
2885
|
-
conversation: {
|
|
2886
|
-
channel: "slack",
|
|
2887
|
-
accountId: account.accountId,
|
|
2888
|
-
conversationId: runtimeBindingThreadId,
|
|
2889
|
-
parentConversationId: baseConversationId
|
|
2890
|
-
}
|
|
2891
|
-
}) : null;
|
|
2892
|
-
const runtimeRoute = eventScope ? {
|
|
2893
|
-
route,
|
|
2894
|
-
bindingRecord: null,
|
|
2895
|
-
boundSessionKey: void 0
|
|
2896
|
-
} : boundThreadRoute?.boundSessionKey || boundThreadRoute?.bindingRecord ? boundThreadRoute : resolveRuntimeConversationBindingRoute({
|
|
2897
|
-
route,
|
|
2898
|
-
conversation: {
|
|
2899
|
-
channel: "slack",
|
|
2900
|
-
accountId: account.accountId,
|
|
2901
|
-
conversationId: baseConversationId
|
|
2902
|
-
}
|
|
2903
|
-
});
|
|
2904
|
-
let configuredBinding = null;
|
|
2905
|
-
let configuredBindingSessionKey = "";
|
|
2906
|
-
if (runtimeRoute.boundSessionKey || runtimeRoute.bindingRecord) route = runtimeRoute.route;
|
|
2907
|
-
else if (!eventScope) {
|
|
2908
|
-
const configuredRoute = resolveConfiguredBindingRoute({
|
|
2909
|
-
cfg: ctx.cfg,
|
|
2910
|
-
route,
|
|
2911
|
-
conversation: {
|
|
2912
|
-
channel: "slack",
|
|
2913
|
-
accountId: account.accountId,
|
|
2914
|
-
conversationId: baseConversationId
|
|
2915
|
-
}
|
|
2916
|
-
});
|
|
2917
|
-
configuredBinding = configuredRoute.bindingResolution;
|
|
2918
|
-
configuredBindingSessionKey = configuredRoute.boundSessionKey ?? "";
|
|
2919
|
-
route = configuredRoute.route;
|
|
2920
|
-
}
|
|
2921
|
-
const threadKeys = runtimeRoute.boundSessionKey || configuredBindingSessionKey ? {
|
|
2922
|
-
sessionKey: route.sessionKey,
|
|
2923
|
-
parentSessionKey: void 0
|
|
2924
|
-
} : resolveThreadSessionKeys({
|
|
2925
|
-
baseSessionKey: route.sessionKey,
|
|
2926
|
-
threadId: routedThreadId,
|
|
2927
|
-
parentSessionKey: routedThreadId && ctx.threadInheritParent ? route.sessionKey : void 0
|
|
2928
|
-
});
|
|
2929
|
-
const sessionKey = threadKeys.sessionKey;
|
|
2930
|
-
const historyKey = isThreadReply && ctx.threadHistoryScope === "thread" ? sessionKey : eventScope ? `${account.accountId}:${eventScope.teamId}:${message.channel}` : message.channel;
|
|
2931
|
-
return {
|
|
2932
|
-
route,
|
|
2933
|
-
runtimeBinding: runtimeRoute.bindingRecord,
|
|
2934
|
-
runtimeBoundSessionKey: runtimeRoute.boundSessionKey,
|
|
2935
|
-
configuredBinding,
|
|
2936
|
-
configuredBindingSessionKey,
|
|
2937
|
-
chatType,
|
|
2938
|
-
replyToMode,
|
|
2939
|
-
threadContext,
|
|
2940
|
-
threadTs,
|
|
2941
|
-
isThreadReply,
|
|
2942
|
-
threadKeys,
|
|
2943
|
-
sessionKey,
|
|
2944
|
-
historyKey
|
|
2945
|
-
};
|
|
2946
|
-
}
|
|
2947
|
-
//#endregion
|
|
2948
|
-
//#region extensions/slack/src/monitor/message-handler/prepare-thread-context-root.ts
|
|
2949
|
-
function isSlackThreadAuthorCurrentBot(params) {
|
|
2950
|
-
const { identity, author } = params;
|
|
2951
|
-
if (identity.botUserId && author.userId && author.userId === identity.botUserId) return true;
|
|
2952
|
-
if (identity.botId && author.botId && author.botId === identity.botId) return true;
|
|
2953
|
-
return false;
|
|
2954
|
-
}
|
|
2955
|
-
function resolveSlackThreadHistoryFilterPolicy(params) {
|
|
2956
|
-
if (!params.includeBotStarterAsRootContext || !params.starterTs) return {};
|
|
2957
|
-
return { retainCurrentBotRootTs: params.starterTs };
|
|
2958
|
-
}
|
|
2959
|
-
function applySlackThreadHistoryFilterPolicy(params) {
|
|
2960
|
-
const kept = [];
|
|
2961
|
-
let omittedCurrentBot = 0;
|
|
2962
|
-
for (const entry of params.history) {
|
|
2963
|
-
if (!isSlackThreadAuthorCurrentBot({
|
|
2964
|
-
identity: params.identity,
|
|
2965
|
-
author: entry
|
|
2966
|
-
})) {
|
|
2967
|
-
kept.push(entry);
|
|
2968
|
-
continue;
|
|
2969
|
-
}
|
|
2970
|
-
if (params.policy.retainCurrentBotRootTs && entry.ts === params.policy.retainCurrentBotRootTs) kept.push(entry);
|
|
2971
|
-
else omittedCurrentBot += 1;
|
|
2972
|
-
}
|
|
2973
|
-
return {
|
|
2974
|
-
kept,
|
|
2975
|
-
omittedCurrentBot
|
|
2976
|
-
};
|
|
2977
|
-
}
|
|
2978
|
-
function shouldIncludeBotThreadStarterContext(params) {
|
|
2979
|
-
if (!params.hasStarterText) return false;
|
|
2980
|
-
return params.starterIsCurrentBot && params.isNewThreadSession;
|
|
2981
|
-
}
|
|
2982
|
-
function ensureSlackThreadHistoryHasBotRoot(params) {
|
|
2983
|
-
if (!params.includeBotStarterAsRootContext || !params.threadStarter?.text) return params.history;
|
|
2984
|
-
if (params.history.some((entry) => entry.ts === params.threadStarter?.ts)) return params.history;
|
|
2985
|
-
return [params.threadStarter, ...params.history];
|
|
2986
|
-
}
|
|
2987
|
-
function formatSlackBotStarterThreadLabel(params) {
|
|
2988
|
-
const base = `Slack thread ${params.roomLabel}`;
|
|
2989
|
-
if (!params.starterText) return base;
|
|
2990
|
-
const snippet = formatSlackThreadLabelSnippet(params.starterText).trim();
|
|
2991
|
-
if (!snippet) return base;
|
|
2992
|
-
return `${base} (assistant root): ${snippet}`;
|
|
2993
|
-
}
|
|
2994
|
-
function formatSlackThreadLabelSnippet(text) {
|
|
2995
|
-
return truncateUtf16Safe(text.replace(/\s+/g, " "), 80);
|
|
2996
|
-
}
|
|
2997
|
-
//#endregion
|
|
2998
|
-
//#region extensions/slack/src/monitor/message-handler/prepare-thread-context.ts
|
|
2999
|
-
const loadSlackMediaModule = createLazyRuntimeModule(() => import("./actions-D3NuJvva.js").then((n) => n.g));
|
|
3000
|
-
const SLACK_THREAD_CONTEXT_USER_LOOKUP_CONCURRENCY = 4;
|
|
3001
|
-
function resolveSlackThreadSessionFreshness(params) {
|
|
3002
|
-
return params.ctx.channelRuntime?.session?.resolveEntryResetFreshness?.({
|
|
3003
|
-
defaultAgentId: resolveDefaultAgentId(params.ctx.cfg),
|
|
3004
|
-
storePath: params.storePath,
|
|
3005
|
-
sessionKey: params.sessionKey,
|
|
3006
|
-
sessionCfg: params.ctx.cfg.session,
|
|
3007
|
-
resetType: "thread",
|
|
3008
|
-
resetOverride: resolveChannelResetConfig({
|
|
3009
|
-
sessionCfg: params.ctx.cfg.session,
|
|
3010
|
-
channel: "slack"
|
|
3011
|
-
})
|
|
3012
|
-
});
|
|
3013
|
-
}
|
|
3014
|
-
function isSlackThreadContextSenderAllowed(params) {
|
|
3015
|
-
return resolveInboundSupplementalSenderAllowed({
|
|
3016
|
-
isGroup: true,
|
|
3017
|
-
groupPolicy: params.allowFromLower.length === 0 ? "open" : "allowlist",
|
|
3018
|
-
allowFrom: params.allowFromLower,
|
|
3019
|
-
isSenderAllowed: (allowFrom) => {
|
|
3020
|
-
if (params.botId) return true;
|
|
3021
|
-
if (!params.userId) return false;
|
|
3022
|
-
return resolveSlackAllowListMatch({
|
|
3023
|
-
allowList: allowFrom,
|
|
3024
|
-
id: params.userId,
|
|
3025
|
-
name: params.userName,
|
|
3026
|
-
allowNameMatching: params.allowNameMatching
|
|
3027
|
-
}).allowed;
|
|
3028
|
-
}
|
|
3029
|
-
});
|
|
3030
|
-
}
|
|
3031
|
-
async function resolveSlackThreadUserMap(params) {
|
|
3032
|
-
const uniqueUserIds = [];
|
|
3033
|
-
const seen = /* @__PURE__ */ new Set();
|
|
3034
|
-
for (const item of params.messages) {
|
|
3035
|
-
if (!item.userId || seen.has(item.userId)) continue;
|
|
3036
|
-
seen.add(item.userId);
|
|
3037
|
-
uniqueUserIds.push(item.userId);
|
|
3038
|
-
}
|
|
3039
|
-
const userMap = /* @__PURE__ */ new Map();
|
|
3040
|
-
if (uniqueUserIds.length === 0) return userMap;
|
|
3041
|
-
const { results } = await runTasksWithConcurrency({
|
|
3042
|
-
tasks: uniqueUserIds.map((id) => async () => {
|
|
3043
|
-
const user = await params.ctx.resolveUserName(id, params.eventScope);
|
|
3044
|
-
return user ? {
|
|
3045
|
-
id,
|
|
3046
|
-
user
|
|
3047
|
-
} : null;
|
|
3048
|
-
}),
|
|
3049
|
-
limit: SLACK_THREAD_CONTEXT_USER_LOOKUP_CONCURRENCY
|
|
3050
|
-
});
|
|
3051
|
-
for (const result of results) if (result) userMap.set(result.id, result.user);
|
|
3052
|
-
return userMap;
|
|
3053
|
-
}
|
|
3054
|
-
async function resolveSlackThreadContextData(params) {
|
|
3055
|
-
const botIdentity = {
|
|
3056
|
-
botUserId: params.ctx.botUserId,
|
|
3057
|
-
botId: params.ctx.botId
|
|
3058
|
-
};
|
|
3059
|
-
const isCurrentBotAuthor = (author) => isSlackThreadAuthorCurrentBot({
|
|
3060
|
-
identity: botIdentity,
|
|
3061
|
-
author
|
|
3062
|
-
});
|
|
3063
|
-
let threadStarterBody;
|
|
3064
|
-
let threadHistoryBody;
|
|
3065
|
-
let threadLabel;
|
|
3066
|
-
let threadStarterMedia = null;
|
|
3067
|
-
const threadSessionFreshness = params.isThreadReply && params.threadTs ? resolveSlackThreadSessionFreshness({
|
|
3068
|
-
ctx: params.ctx,
|
|
3069
|
-
storePath: params.storePath,
|
|
3070
|
-
sessionKey: params.sessionKey
|
|
3071
|
-
}) : void 0;
|
|
3072
|
-
const threadSessionPreviousTimestamp = params.isThreadReply && params.threadTs && !threadSessionFreshness ? readSessionUpdatedAt({
|
|
3073
|
-
storePath: params.storePath,
|
|
3074
|
-
sessionKey: params.sessionKey
|
|
3075
|
-
}) : void 0;
|
|
3076
|
-
const shouldSeedInitialThreadContext = Boolean(params.isThreadReply && params.threadTs && (threadSessionFreshness ? threadSessionFreshness.state !== "fresh" : threadSessionPreviousTimestamp === void 0));
|
|
3077
|
-
const shouldLoadInitialThreadHistory = shouldSeedInitialThreadContext || params.forceInitialHistory === true;
|
|
3078
|
-
if (!params.isThreadReply || !params.threadTs) return {
|
|
3079
|
-
threadStarterBody,
|
|
3080
|
-
threadHistoryBody,
|
|
3081
|
-
shouldSeedInitialThreadContext,
|
|
3082
|
-
threadLabel,
|
|
3083
|
-
threadStarterMedia
|
|
3084
|
-
};
|
|
3085
|
-
const starter = params.threadStarter;
|
|
3086
|
-
const starterSenderName = params.allowNameMatching && params.allowFromLower.length > 0 && starter?.userId ? (await params.ctx.resolveUserName(starter.userId, params.eventScope))?.name : void 0;
|
|
3087
|
-
const starterIsCurrentBot = Boolean(starter && isCurrentBotAuthor({
|
|
3088
|
-
userId: starter.userId,
|
|
3089
|
-
botId: starter.botId
|
|
3090
|
-
}));
|
|
3091
|
-
const starterAllowed = !starter || !starterIsCurrentBot && isSlackThreadContextSenderAllowed({
|
|
3092
|
-
allowFromLower: params.allowFromLower,
|
|
3093
|
-
allowNameMatching: params.allowNameMatching,
|
|
3094
|
-
userId: starter.userId,
|
|
3095
|
-
userName: starterSenderName,
|
|
3096
|
-
botId: starter.botId
|
|
3097
|
-
});
|
|
3098
|
-
const includeStarterContext = !starter || !starterIsCurrentBot && shouldIncludeSupplementalContext({
|
|
3099
|
-
mode: params.contextVisibilityMode,
|
|
3100
|
-
kind: "thread",
|
|
3101
|
-
senderAllowed: starterAllowed
|
|
3102
|
-
});
|
|
3103
|
-
if (starter?.text && includeStarterContext) {
|
|
3104
|
-
threadStarterBody = starter.text;
|
|
3105
|
-
const snippet = formatSlackThreadLabelSnippet(starter.text);
|
|
3106
|
-
threadLabel = `Slack thread ${params.roomLabel}${snippet ? `: ${snippet}` : ""}`;
|
|
3107
|
-
if (shouldSeedInitialThreadContext && !params.effectiveDirectMedia && starter.files && starter.files.length > 0) {
|
|
3108
|
-
const { resolveSlackMedia } = await loadSlackMediaModule();
|
|
3109
|
-
threadStarterMedia = await resolveSlackMedia({
|
|
3110
|
-
files: starter.files,
|
|
3111
|
-
client: params.eventScope?.client ?? params.ctx.app.client,
|
|
3112
|
-
token: params.ctx.botToken,
|
|
3113
|
-
maxBytes: params.ctx.mediaMaxBytes
|
|
3114
|
-
});
|
|
3115
|
-
if (threadStarterMedia) logVerbose(`slack: hydrated thread starter file ${threadStarterMedia.map((item) => item.placeholder).join(", ")} from root message`);
|
|
3116
|
-
}
|
|
3117
|
-
} else threadLabel = `Slack thread ${params.roomLabel}`;
|
|
3118
|
-
const includeBotStarterAsRootContext = shouldIncludeBotThreadStarterContext({
|
|
3119
|
-
starterIsCurrentBot,
|
|
3120
|
-
isNewThreadSession: shouldSeedInitialThreadContext,
|
|
3121
|
-
hasStarterText: Boolean(starter?.text)
|
|
3122
|
-
});
|
|
3123
|
-
if (starter?.text && starterIsCurrentBot && !includeBotStarterAsRootContext) logVerbose("slack: omitted current-bot thread starter from context");
|
|
3124
|
-
else if (starter?.text && !includeStarterContext && !starterIsCurrentBot) logVerbose(`slack: omitted thread starter from context (mode=${params.contextVisibilityMode}, sender_allowed=${starterAllowed ? "yes" : "no"})`);
|
|
3125
|
-
else if (includeBotStarterAsRootContext) {
|
|
3126
|
-
threadLabel = formatSlackBotStarterThreadLabel({
|
|
3127
|
-
roomLabel: params.roomLabel,
|
|
3128
|
-
starterText: starter?.text
|
|
3129
|
-
});
|
|
3130
|
-
logVerbose("slack: retained current-bot thread starter as assistant root context");
|
|
3131
|
-
}
|
|
3132
|
-
const threadInitialHistoryLimit = params.account.config?.thread?.initialHistoryLimit ?? 20;
|
|
3133
|
-
if (threadInitialHistoryLimit > 0 && shouldLoadInitialThreadHistory) {
|
|
3134
|
-
const currentBotRootTs = starter?.ts ?? params.threadTs;
|
|
3135
|
-
const threadHistoryWithBotRoot = ensureSlackThreadHistoryHasBotRoot({
|
|
3136
|
-
history: await resolveSlackThreadHistory({
|
|
3137
|
-
channelId: params.message.channel,
|
|
3138
|
-
threadTs: params.threadTs,
|
|
3139
|
-
client: params.eventScope?.client ?? params.ctx.app.client,
|
|
3140
|
-
currentMessageTs: params.message.ts,
|
|
3141
|
-
limit: threadInitialHistoryLimit
|
|
3142
|
-
}),
|
|
3143
|
-
includeBotStarterAsRootContext,
|
|
3144
|
-
threadStarter: starter ? {
|
|
3145
|
-
...starter,
|
|
3146
|
-
ts: currentBotRootTs
|
|
3147
|
-
} : null
|
|
3148
|
-
});
|
|
3149
|
-
if (threadHistoryWithBotRoot.length > 0) {
|
|
3150
|
-
const { kept: threadHistoryWithoutCurrentBot, omittedCurrentBot: omittedCurrentBotHistoryCount } = applySlackThreadHistoryFilterPolicy({
|
|
3151
|
-
history: threadHistoryWithBotRoot,
|
|
3152
|
-
policy: resolveSlackThreadHistoryFilterPolicy({
|
|
3153
|
-
includeBotStarterAsRootContext,
|
|
3154
|
-
starterTs: currentBotRootTs
|
|
3155
|
-
}),
|
|
3156
|
-
identity: botIdentity
|
|
3157
|
-
});
|
|
3158
|
-
const userMapForFilter = params.contextVisibilityMode !== "all" && params.allowNameMatching && params.allowFromLower.length > 0 ? await resolveSlackThreadUserMap({
|
|
3159
|
-
ctx: params.ctx,
|
|
3160
|
-
messages: threadHistoryWithoutCurrentBot,
|
|
3161
|
-
eventScope: params.eventScope
|
|
3162
|
-
}) : /* @__PURE__ */ new Map();
|
|
3163
|
-
const { items: filteredThreadHistory, omitted: omittedHistoryCount } = params.contextVisibilityMode === "all" ? {
|
|
3164
|
-
items: threadHistoryWithoutCurrentBot,
|
|
3165
|
-
omitted: 0
|
|
3166
|
-
} : filterSupplementalContextItems({
|
|
3167
|
-
items: threadHistoryWithoutCurrentBot,
|
|
3168
|
-
mode: params.contextVisibilityMode,
|
|
3169
|
-
kind: "thread",
|
|
3170
|
-
isSenderAllowed: (historyMsg) => {
|
|
3171
|
-
if (isCurrentBotAuthor({
|
|
3172
|
-
userId: historyMsg.userId,
|
|
3173
|
-
botId: historyMsg.botId
|
|
3174
|
-
})) return true;
|
|
3175
|
-
const msgUser = historyMsg.userId ? userMapForFilter.get(historyMsg.userId) : null;
|
|
3176
|
-
return isSlackThreadContextSenderAllowed({
|
|
3177
|
-
allowFromLower: params.allowFromLower,
|
|
3178
|
-
allowNameMatching: params.allowNameMatching,
|
|
3179
|
-
userId: historyMsg.userId,
|
|
3180
|
-
userName: msgUser?.name,
|
|
3181
|
-
botId: historyMsg.botId
|
|
3182
|
-
});
|
|
3183
|
-
}
|
|
3184
|
-
});
|
|
3185
|
-
const userMap = await resolveSlackThreadUserMap({
|
|
3186
|
-
ctx: params.ctx,
|
|
3187
|
-
messages: filteredThreadHistory
|
|
3188
|
-
});
|
|
3189
|
-
if (omittedHistoryCount > 0 || omittedCurrentBotHistoryCount > 0) logVerbose(`slack: omitted ${omittedHistoryCount + omittedCurrentBotHistoryCount} thread message(s) from context (mode=${params.contextVisibilityMode})`);
|
|
3190
|
-
const historyParts = [];
|
|
3191
|
-
for (const historyMsg of filteredThreadHistory) {
|
|
3192
|
-
const msgUser = historyMsg.userId ? userMap.get(historyMsg.userId) : null;
|
|
3193
|
-
const isOtherBot = Boolean(historyMsg.botId) && historyMsg.botId !== params.ctx.botId;
|
|
3194
|
-
const isCurrentBot = isCurrentBotAuthor({
|
|
3195
|
-
userId: historyMsg.userId,
|
|
3196
|
-
botId: historyMsg.botId
|
|
3197
|
-
});
|
|
3198
|
-
const role = isCurrentBot || isOtherBot || Boolean(historyMsg.botId) ? "assistant" : "user";
|
|
3199
|
-
const msgSenderName = isCurrentBot ? "Bot (this assistant)" : msgUser?.name ?? (historyMsg.botId ? `Bot (${historyMsg.botId})` : "Unknown");
|
|
3200
|
-
const msgWithId = `${historyMsg.text}\n[slack message id: ${historyMsg.ts ?? "unknown"} channel: ${params.message.channel}]`;
|
|
3201
|
-
historyParts.push(formatInboundEnvelope({
|
|
3202
|
-
channel: "Slack",
|
|
3203
|
-
from: `${msgSenderName} (${role})`,
|
|
3204
|
-
timestamp: resolveSlackTimestampMs(historyMsg.ts),
|
|
3205
|
-
body: msgWithId,
|
|
3206
|
-
chatType: "channel",
|
|
3207
|
-
envelope: params.envelopeOptions
|
|
3208
|
-
}));
|
|
3209
|
-
}
|
|
3210
|
-
if (historyParts.length > 0) {
|
|
3211
|
-
threadHistoryBody = historyParts.join("\n\n");
|
|
3212
|
-
logVerbose(`slack: populated thread history with ${filteredThreadHistory.length} messages for new session`);
|
|
3213
|
-
}
|
|
3214
|
-
}
|
|
3215
|
-
}
|
|
3216
|
-
return {
|
|
3217
|
-
threadStarterBody,
|
|
3218
|
-
threadHistoryBody,
|
|
3219
|
-
shouldSeedInitialThreadContext,
|
|
3220
|
-
threadLabel,
|
|
3221
|
-
threadStarterMedia
|
|
3222
|
-
};
|
|
3223
|
-
}
|
|
3224
|
-
//#endregion
|
|
3225
|
-
//#region extensions/slack/src/monitor/message-handler/subteam-mentions.ts
|
|
3226
|
-
const SUBTEAM_MENTION_RE = /<!subteam\^([A-Z0-9]+)(?:\|[^>]*)?>/gi;
|
|
3227
|
-
const SUBTEAM_MEMBER_CACHE_TTL_MS = 300 * 1e3;
|
|
3228
|
-
const subteamMemberCache = /* @__PURE__ */ new WeakMap();
|
|
3229
|
-
function normalizeSlackId(value) {
|
|
3230
|
-
return typeof value === "string" && value.trim() ? value.trim().toUpperCase() : void 0;
|
|
3231
|
-
}
|
|
3232
|
-
function extractSlackSubteamMentionIds(text) {
|
|
3233
|
-
if (!text) return [];
|
|
3234
|
-
const ids = /* @__PURE__ */ new Set();
|
|
3235
|
-
for (const match of text.matchAll(SUBTEAM_MENTION_RE)) {
|
|
3236
|
-
const id = normalizeSlackId(match[1]);
|
|
3237
|
-
if (id) ids.add(id);
|
|
3238
|
-
}
|
|
3239
|
-
return [...ids];
|
|
3240
|
-
}
|
|
3241
|
-
async function readSlackSubteamUsers(params) {
|
|
3242
|
-
let bySubteam = subteamMemberCache.get(params.client);
|
|
3243
|
-
if (!bySubteam) {
|
|
3244
|
-
bySubteam = /* @__PURE__ */ new Map();
|
|
3245
|
-
subteamMemberCache.set(params.client, bySubteam);
|
|
3246
|
-
}
|
|
3247
|
-
const cacheKey = `${normalizeSlackId(params.teamId) ?? ""}:${params.subteamId}`;
|
|
3248
|
-
const cached = bySubteam.get(cacheKey);
|
|
3249
|
-
const now = asDateTimestampMs(params.now);
|
|
3250
|
-
if (cached) {
|
|
3251
|
-
if (now !== void 0 && asDateTimestampMs(cached.expiresAt) !== void 0 && cached.expiresAt > now) return cached.users;
|
|
3252
|
-
bySubteam.delete(cacheKey);
|
|
3253
|
-
}
|
|
3254
|
-
try {
|
|
3255
|
-
const response = await params.client.usergroups.users.list({
|
|
3256
|
-
usergroup: params.subteamId,
|
|
3257
|
-
...params.teamId ? { team_id: params.teamId } : {}
|
|
3258
|
-
});
|
|
3259
|
-
if (!response.ok) {
|
|
3260
|
-
params.log?.(`slack: failed to resolve user-group mention ${params.subteamId}: ${response.error ?? "unknown_error"}`);
|
|
3261
|
-
return /* @__PURE__ */ new Set();
|
|
3262
|
-
}
|
|
3263
|
-
const users = new Set((response.users ?? []).map((userId) => normalizeSlackId(userId)).filter(Boolean));
|
|
3264
|
-
const expiresAt = resolveExpiresAtMsFromDurationMs(SUBTEAM_MEMBER_CACHE_TTL_MS, { nowMs: params.now });
|
|
3265
|
-
if (expiresAt !== void 0) bySubteam.set(cacheKey, {
|
|
3266
|
-
expiresAt,
|
|
3267
|
-
users
|
|
3268
|
-
});
|
|
3269
|
-
return users;
|
|
3270
|
-
} catch (err) {
|
|
3271
|
-
params.log?.(`slack: failed to resolve user-group mention ${params.subteamId}: ${formatErrorMessage(err)}`);
|
|
3272
|
-
return /* @__PURE__ */ new Set();
|
|
3273
|
-
}
|
|
3274
|
-
}
|
|
3275
|
-
async function isSlackSubteamMentionForBot(params) {
|
|
3276
|
-
const botUserId = normalizeSlackId(params.botUserId);
|
|
3277
|
-
if (!botUserId) return false;
|
|
3278
|
-
const subteamIds = extractSlackSubteamMentionIds(params.text);
|
|
3279
|
-
if (subteamIds.length === 0) return false;
|
|
3280
|
-
const now = params.now ?? Date.now();
|
|
3281
|
-
for (const subteamId of subteamIds) if ((await readSlackSubteamUsers({
|
|
3282
|
-
client: params.client,
|
|
3283
|
-
subteamId,
|
|
3284
|
-
teamId: normalizeOptionalString(params.teamId),
|
|
3285
|
-
now,
|
|
3286
|
-
log: params.log
|
|
3287
|
-
})).has(botUserId)) return true;
|
|
3288
|
-
return false;
|
|
3289
|
-
}
|
|
3290
|
-
//#endregion
|
|
3291
|
-
//#region extensions/slack/src/monitor/message-handler/prepare.ts
|
|
3292
|
-
const mentionRegexCache = /* @__PURE__ */ new WeakMap();
|
|
3293
|
-
const SLACK_ANY_MENTION_RE = /<@[^>]+>|<!subteam\^[^>]+>/;
|
|
3294
|
-
const SLACK_USER_MENTION_RE = /<@([^>|]+)(?:\|[^>]+)?>/g;
|
|
3295
|
-
const SLACK_SUBTEAM_MENTION_RE = /<!subteam\^([^>|]+)(?:\|[^>]+)?>/g;
|
|
3296
|
-
const SLACK_SUBTEAM_MENTION_MARKER = "<!subteam^";
|
|
3297
|
-
const SLACK_HISTORY_MEDIA_MAX_ATTACHMENTS = 4;
|
|
3298
|
-
const SLACK_HISTORY_MEDIA_MAX_BYTES = 10 * 1024 * 1024;
|
|
3299
|
-
const SLACK_HISTORY_MEDIA_IDLE_TIMEOUT_MS = 1e3;
|
|
3300
|
-
const SLACK_HISTORY_MEDIA_TOTAL_TIMEOUT_MS = 3e3;
|
|
3301
|
-
function recordString(record, key) {
|
|
3302
|
-
return normalizeOptionalString(record?.[key]);
|
|
3303
|
-
}
|
|
3304
|
-
function recordNullableString(record, key) {
|
|
3305
|
-
if (!record || !(key in record)) return;
|
|
3306
|
-
if (record[key] === null) return null;
|
|
3307
|
-
return normalizeOptionalString(record[key]);
|
|
3308
|
-
}
|
|
3309
|
-
function mergeSlackAssistantThreadContext(primary, fallback) {
|
|
3310
|
-
if (!primary) return fallback;
|
|
3311
|
-
if (!fallback) return primary;
|
|
3312
|
-
return {
|
|
3313
|
-
assistantChannelId: primary.assistantChannelId || fallback.assistantChannelId,
|
|
3314
|
-
threadTs: primary.threadTs || fallback.threadTs,
|
|
3315
|
-
userId: primary.userId ?? fallback.userId,
|
|
3316
|
-
channelId: primary.channelId ?? fallback.channelId,
|
|
3317
|
-
teamId: primary.teamId ?? fallback.teamId,
|
|
3318
|
-
enterpriseId: primary.enterpriseId !== void 0 ? primary.enterpriseId : fallback.enterpriseId
|
|
3319
|
-
};
|
|
3320
|
-
}
|
|
3321
|
-
function hasSlackAssistantThreadMetadata(context) {
|
|
3322
|
-
return Boolean(context?.channelId || context?.teamId || context?.enterpriseId !== void 0);
|
|
3323
|
-
}
|
|
3324
|
-
function resolveSlackMessageAssistantThreadContext(message) {
|
|
3325
|
-
const thread = asOptionalRecord(message.assistant_thread);
|
|
3326
|
-
if (!thread) return;
|
|
3327
|
-
const context = asOptionalRecord(thread.context);
|
|
3328
|
-
const assistantChannelId = recordString(thread, "channel_id") ?? message.channel;
|
|
3329
|
-
const threadTs = recordString(thread, "thread_ts") ?? message.thread_ts ?? message.ts;
|
|
3330
|
-
if (!assistantChannelId || !threadTs) return;
|
|
3331
|
-
return {
|
|
3332
|
-
assistantChannelId,
|
|
3333
|
-
threadTs,
|
|
3334
|
-
userId: recordString(thread, "user_id") ?? message.user,
|
|
3335
|
-
channelId: recordString(context, "channel_id"),
|
|
3336
|
-
teamId: recordString(context, "team_id"),
|
|
3337
|
-
enterpriseId: recordNullableString(context, "enterprise_id")
|
|
3338
|
-
};
|
|
3339
|
-
}
|
|
3340
|
-
async function restoreSlackAssistantThreadContextFromMetadata(params) {
|
|
3341
|
-
const threadTs = params.message.thread_ts;
|
|
3342
|
-
const parentUserId = params.message.parent_user_id?.trim();
|
|
3343
|
-
if (!params.message.channel || !threadTs || !parentUserId || parentUserId !== params.ctx.botUserId && parentUserId !== params.ctx.botId) return;
|
|
3344
|
-
try {
|
|
3345
|
-
const response = await (params.eventScope?.client ?? params.ctx.app.client).conversations.replies({
|
|
3346
|
-
channel: params.message.channel,
|
|
3347
|
-
ts: threadTs,
|
|
3348
|
-
oldest: threadTs,
|
|
3349
|
-
include_all_metadata: true,
|
|
3350
|
-
limit: 4
|
|
3351
|
-
});
|
|
3352
|
-
for (const message of response.messages ?? []) {
|
|
3353
|
-
const context = parseSlackAssistantThreadMetadata(message.metadata);
|
|
3354
|
-
if (!context) continue;
|
|
3355
|
-
return {
|
|
3356
|
-
assistantChannelId: params.message.channel,
|
|
3357
|
-
threadTs,
|
|
3358
|
-
userId: params.message.user,
|
|
3359
|
-
channelId: context.channelId,
|
|
3360
|
-
teamId: context.teamId,
|
|
3361
|
-
enterpriseId: context.enterpriseId
|
|
3362
|
-
};
|
|
3363
|
-
}
|
|
3364
|
-
} catch (err) {
|
|
3365
|
-
logVerbose(`slack assistant context restore failed channel=${params.message.channel} ts=${threadTs}: ${formatErrorMessage(err)}`);
|
|
3366
|
-
}
|
|
3367
|
-
}
|
|
3368
|
-
function resolveCachedMentionRegexes(ctx, agentId, options) {
|
|
3369
|
-
const key = [
|
|
3370
|
-
normalizeOptionalString(agentId) ?? "__default__",
|
|
3371
|
-
normalizeOptionalString(options?.provider),
|
|
3372
|
-
normalizeOptionalString(options?.conversationId ?? void 0),
|
|
3373
|
-
options?.providerPolicy ? JSON.stringify(options.providerPolicy) : ""
|
|
3374
|
-
].join("");
|
|
3375
|
-
let byAgent = mentionRegexCache.get(ctx);
|
|
3376
|
-
if (!byAgent) {
|
|
3377
|
-
byAgent = /* @__PURE__ */ new Map();
|
|
3378
|
-
mentionRegexCache.set(ctx, byAgent);
|
|
3379
|
-
}
|
|
3380
|
-
const cached = byAgent.get(key);
|
|
3381
|
-
if (cached) return cached;
|
|
3382
|
-
const built = buildMentionRegexes(ctx.cfg, agentId, options);
|
|
3383
|
-
byAgent.set(key, built);
|
|
3384
|
-
return built;
|
|
3385
|
-
}
|
|
3386
|
-
function isSlackImageFileCandidate(file) {
|
|
3387
|
-
if ((file.mimetype?.split(";")[0]?.trim().toLowerCase())?.startsWith("image/")) return true;
|
|
3388
|
-
return Boolean(mimeTypeFromFilePath(file.name)?.startsWith("image/"));
|
|
3389
|
-
}
|
|
3390
|
-
function sliceSlackImageFileCandidates(files, limit) {
|
|
3391
|
-
if (limit <= 0 || !files?.length) return [];
|
|
3392
|
-
return files.filter(isSlackImageFileCandidate).slice(0, limit);
|
|
3393
|
-
}
|
|
3394
|
-
function sliceSlackHistoryAttachmentCandidates(attachments, limit) {
|
|
3395
|
-
if (limit <= 0 || !attachments?.length) return [];
|
|
3396
|
-
const out = [];
|
|
3397
|
-
let remaining = limit;
|
|
3398
|
-
for (const attachment of attachments) {
|
|
3399
|
-
if (attachment.is_share !== true) continue;
|
|
3400
|
-
const hasImageUrl = Boolean(normalizeOptionalString(attachment.image_url));
|
|
3401
|
-
const files = sliceSlackImageFileCandidates(attachment.files, remaining - (hasImageUrl ? 1 : 0));
|
|
3402
|
-
if (!hasImageUrl && files.length === 0) continue;
|
|
3403
|
-
out.push({
|
|
3404
|
-
...attachment,
|
|
3405
|
-
files
|
|
3406
|
-
});
|
|
3407
|
-
remaining -= (hasImageUrl ? 1 : 0) + files.length;
|
|
3408
|
-
if (remaining <= 0) break;
|
|
3409
|
-
}
|
|
3410
|
-
return out;
|
|
3411
|
-
}
|
|
3412
|
-
function buildSlackHistoryMediaCandidateMessage(message) {
|
|
3413
|
-
const files = sliceSlackImageFileCandidates(message.files, SLACK_HISTORY_MEDIA_MAX_ATTACHMENTS);
|
|
3414
|
-
const attachments = sliceSlackHistoryAttachmentCandidates(message.attachments, Math.max(0, SLACK_HISTORY_MEDIA_MAX_ATTACHMENTS - files.length));
|
|
3415
|
-
if (files.length === 0 && attachments.length === 0) return null;
|
|
3416
|
-
return {
|
|
3417
|
-
...message,
|
|
3418
|
-
files,
|
|
3419
|
-
attachments
|
|
3420
|
-
};
|
|
3421
|
-
}
|
|
3422
|
-
async function resolveSlackHistoryMediaForPendingRecord(params) {
|
|
3423
|
-
const mediaMessage = buildSlackHistoryMediaCandidateMessage(params.message);
|
|
3424
|
-
if (!mediaMessage) return [];
|
|
3425
|
-
return await toInboundMediaFactsWithMetadata((await resolveSlackMessageContent({
|
|
3426
|
-
message: mediaMessage,
|
|
3427
|
-
isThreadReply: params.isThreadReply,
|
|
3428
|
-
threadStarter: params.threadStarter,
|
|
3429
|
-
isBotMessage: params.isBotMessage,
|
|
3430
|
-
client: params.eventScope?.client ?? params.ctx.app.client,
|
|
3431
|
-
botToken: params.ctx.botToken,
|
|
3432
|
-
mediaMaxBytes: Math.min(params.ctx.mediaMaxBytes, SLACK_HISTORY_MEDIA_MAX_BYTES),
|
|
3433
|
-
mediaReadIdleTimeoutMs: SLACK_HISTORY_MEDIA_IDLE_TIMEOUT_MS,
|
|
3434
|
-
mediaTotalTimeoutMs: SLACK_HISTORY_MEDIA_TOTAL_TIMEOUT_MS
|
|
3435
|
-
}))?.effectiveDirectMedia, {
|
|
3436
|
-
kind: "image",
|
|
3437
|
-
messageId: params.message.ts
|
|
3438
|
-
});
|
|
3439
|
-
}
|
|
3440
|
-
function collectUniqueSlackMentionIds(text, regex) {
|
|
3441
|
-
const ids = [];
|
|
3442
|
-
regex.lastIndex = 0;
|
|
3443
|
-
for (const match of text.matchAll(regex)) {
|
|
3444
|
-
const id = normalizeSlackId(match[1]);
|
|
3445
|
-
if (id && !ids.includes(id)) ids.push(id);
|
|
3446
|
-
}
|
|
3447
|
-
return ids;
|
|
3448
|
-
}
|
|
3449
|
-
function collectSlackMentionMetadata(text) {
|
|
3450
|
-
return {
|
|
3451
|
-
mentionedUserIds: collectUniqueSlackMentionIds(text, SLACK_USER_MENTION_RE),
|
|
3452
|
-
mentionedSubteamIds: collectUniqueSlackMentionIds(text, SLACK_SUBTEAM_MENTION_RE),
|
|
3453
|
-
hasAnyMention: SLACK_ANY_MENTION_RE.test(text),
|
|
3454
|
-
hasSubteamMention: text.includes(SLACK_SUBTEAM_MENTION_MARKER)
|
|
3455
|
-
};
|
|
3456
|
-
}
|
|
3457
|
-
async function resolveSlackExplicitMentionState(params) {
|
|
3458
|
-
const normalizedBotUserId = normalizeSlackId(params.ctx.botUserId);
|
|
3459
|
-
const explicitlyMentionedBotUser = Boolean(normalizedBotUserId && params.mentionedUserIds.includes(normalizedBotUserId));
|
|
3460
|
-
const explicitlyMentionedBotSubteam = Boolean(params.ctx.botUserId && params.hasSubteamMention) && await isSlackSubteamMentionForBot({
|
|
3461
|
-
client: params.eventScope?.client ?? params.ctx.app.client,
|
|
3462
|
-
text: params.messageText,
|
|
3463
|
-
botUserId: params.ctx.botUserId,
|
|
3464
|
-
teamId: params.eventScope?.teamId ?? params.ctx.teamId,
|
|
3465
|
-
log: logVerbose
|
|
3466
|
-
});
|
|
3467
|
-
return {
|
|
3468
|
-
explicitlyMentionedBotUser,
|
|
3469
|
-
explicitlyMentionedBotSubteam,
|
|
3470
|
-
explicitlyMentioned: explicitlyMentionedBotUser || explicitlyMentionedBotSubteam || params.source === "app_mention"
|
|
3471
|
-
};
|
|
3472
|
-
}
|
|
3473
|
-
function resolveSlackMentionSource(params) {
|
|
3474
|
-
if (params.explicitBotMention) return "explicit_bot";
|
|
3475
|
-
if (params.explicitSubteamMention) return "subteam";
|
|
3476
|
-
if (params.shouldBypassMention) return "command_bypass";
|
|
3477
|
-
if (params.wasMentioned) return "mention_pattern";
|
|
3478
|
-
if (params.matchedImplicitMentionKinds.length > 0) return "implicit_thread";
|
|
3479
|
-
return "none";
|
|
3480
|
-
}
|
|
3481
|
-
function buildSlackMentionContextPayload(params) {
|
|
3482
|
-
if (!params.isRoomish) return {};
|
|
3483
|
-
return {
|
|
3484
|
-
WasMentioned: params.effectiveWasMentioned,
|
|
3485
|
-
ExplicitlyMentionedBot: params.explicitlyMentioned,
|
|
3486
|
-
MentionedUserIds: params.mentionedUserIds.length > 0 ? [...params.mentionedUserIds] : void 0,
|
|
3487
|
-
MentionedSubteamIds: params.mentionedSubteamIds.length > 0 ? [...params.mentionedSubteamIds] : void 0,
|
|
3488
|
-
ImplicitMentionKinds: params.matchedImplicitMentionKinds.length > 0 ? [...params.matchedImplicitMentionKinds] : void 0,
|
|
3489
|
-
MentionSource: params.mentionSource
|
|
3490
|
-
};
|
|
3491
|
-
}
|
|
3492
|
-
async function resolveSlackConversationContext(params) {
|
|
3493
|
-
const { ctx, account, message } = params;
|
|
3494
|
-
const cfg = ctx.cfg;
|
|
3495
|
-
let channelInfo = {};
|
|
3496
|
-
let resolvedChannelType = normalizeSlackChannelType(message.channel_type, message.channel);
|
|
3497
|
-
if (resolvedChannelType !== "im" && (!message.channel_type || message.channel_type !== "im")) {
|
|
3498
|
-
channelInfo = await ctx.resolveChannelName(message.channel, params.eventScope);
|
|
3499
|
-
resolvedChannelType = normalizeSlackChannelType(message.channel_type ?? channelInfo.type ?? ctx.recallSlackChannelType(message.channel, params.eventScope), message.channel);
|
|
3500
|
-
}
|
|
3501
|
-
const channelName = channelInfo?.name;
|
|
3502
|
-
const isDirectMessage = resolvedChannelType === "im";
|
|
3503
|
-
const isGroupDm = resolvedChannelType === "mpim";
|
|
3504
|
-
const isRoom = resolvedChannelType === "channel" || resolvedChannelType === "group";
|
|
3505
|
-
const isRoomish = isRoom || isGroupDm;
|
|
3506
|
-
const channelConfig = isRoom ? resolveSlackChannelConfig({
|
|
3507
|
-
channelId: message.channel,
|
|
3508
|
-
channelName,
|
|
3509
|
-
channels: ctx.channelsConfig,
|
|
3510
|
-
channelKeys: ctx.channelsConfigKeys,
|
|
3511
|
-
defaultRequireMention: ctx.defaultRequireMention,
|
|
3512
|
-
allowNameMatching: ctx.allowNameMatching
|
|
3513
|
-
}) : null;
|
|
3514
|
-
const allowBotsSetting = channelConfig?.allowBots ?? account.config?.allowBots ?? cfg.channels?.slack?.allowBots ?? false;
|
|
3515
|
-
return {
|
|
3516
|
-
channelInfo,
|
|
3517
|
-
channelName,
|
|
3518
|
-
resolvedChannelType,
|
|
3519
|
-
isDirectMessage,
|
|
3520
|
-
isGroupDm,
|
|
3521
|
-
isRoom,
|
|
3522
|
-
isRoomish,
|
|
3523
|
-
channelConfig,
|
|
3524
|
-
allowBotsMode: allowBotsSetting === "mentions" ? "mentions" : allowBotsSetting ? "all" : "off",
|
|
3525
|
-
isBotMessage: Boolean(message.bot_id)
|
|
3526
|
-
};
|
|
3527
|
-
}
|
|
3528
|
-
async function authorizeSlackInboundMessage(params) {
|
|
3529
|
-
const { ctx, account, message, conversation } = params;
|
|
3530
|
-
const { isDirectMessage, channelName, resolvedChannelType, isBotMessage, allowBotsMode } = conversation;
|
|
3531
|
-
if (isBotMessage) {
|
|
3532
|
-
if (message.user && ctx.botUserId && message.user === ctx.botUserId) return null;
|
|
3533
|
-
if (allowBotsMode === "off") {
|
|
3534
|
-
logVerbose(`slack: drop bot message ${message.bot_id ?? "unknown"} (allowBots=false)`);
|
|
3535
|
-
return null;
|
|
3536
|
-
}
|
|
3537
|
-
}
|
|
3538
|
-
if (isDirectMessage && !message.user) {
|
|
3539
|
-
logVerbose("slack: drop dm message (missing user id)");
|
|
3540
|
-
return null;
|
|
3541
|
-
}
|
|
3542
|
-
const senderId = message.user ?? (isBotMessage ? message.bot_id : void 0);
|
|
3543
|
-
if (!senderId) {
|
|
3544
|
-
logVerbose("slack: drop message (missing sender id)");
|
|
3545
|
-
return null;
|
|
3546
|
-
}
|
|
3547
|
-
if (!ctx.isChannelAllowed({
|
|
3548
|
-
channelId: message.channel,
|
|
3549
|
-
channelName,
|
|
3550
|
-
channelType: resolvedChannelType
|
|
3551
|
-
})) {
|
|
3552
|
-
logVerbose("slack: drop message (channel not allowed)");
|
|
3553
|
-
return null;
|
|
3554
|
-
}
|
|
3555
|
-
const allowFromLower = await resolveSlackEffectiveAllowFrom(ctx, { includePairingStore: isDirectMessage });
|
|
3556
|
-
if (isDirectMessage) {
|
|
3557
|
-
const directUserId = message.user;
|
|
3558
|
-
if (!directUserId) {
|
|
3559
|
-
logVerbose("slack: drop dm message (missing user id)");
|
|
3560
|
-
return null;
|
|
3561
|
-
}
|
|
3562
|
-
if (!await authorizeSlackDirectMessage({
|
|
3563
|
-
ctx,
|
|
3564
|
-
accountId: account.accountId,
|
|
3565
|
-
senderId: directUserId,
|
|
3566
|
-
allowFromLower,
|
|
3567
|
-
resolveSenderName: (userId) => ctx.resolveUserName(userId, params.eventScope),
|
|
3568
|
-
sendPairingReply: async (text) => {
|
|
3569
|
-
await sendMessageSlack(message.channel, text, {
|
|
3570
|
-
cfg: ctx.cfg,
|
|
3571
|
-
token: ctx.botToken,
|
|
3572
|
-
client: params.eventScope?.client ?? ctx.app.client,
|
|
3573
|
-
accountId: account.accountId
|
|
3574
|
-
});
|
|
3575
|
-
},
|
|
3576
|
-
onDisabled: () => {
|
|
3577
|
-
logVerbose("slack: drop dm (dms disabled)");
|
|
3578
|
-
},
|
|
3579
|
-
onUnauthorized: ({ allowMatchMeta }) => {
|
|
3580
|
-
logVerbose(`Blocked unauthorized slack sender ${message.user} (dmPolicy=${ctx.dmPolicy}, ${allowMatchMeta})`);
|
|
3581
|
-
},
|
|
3582
|
-
log: logVerbose
|
|
3583
|
-
})) return null;
|
|
3584
|
-
}
|
|
3585
|
-
return {
|
|
3586
|
-
senderId,
|
|
3587
|
-
allowFromLower
|
|
3588
|
-
};
|
|
3589
|
-
}
|
|
3590
|
-
async function prepareSlackMessage(params) {
|
|
3591
|
-
const { ctx, account, message, opts } = params;
|
|
3592
|
-
const slackClient = opts.eventScope?.client ?? ctx.app.client;
|
|
3593
|
-
const threadStarterWorkspaceScope = opts.eventScope ? {
|
|
3594
|
-
accountId: account.accountId,
|
|
3595
|
-
teamId: opts.eventScope.teamId
|
|
3596
|
-
} : void 0;
|
|
3597
|
-
const cfg = ctx.cfg;
|
|
3598
|
-
const conversation = await resolveSlackConversationContext({
|
|
3599
|
-
ctx,
|
|
3600
|
-
account,
|
|
3601
|
-
message,
|
|
3602
|
-
eventScope: opts.eventScope
|
|
3603
|
-
});
|
|
3604
|
-
const { channelInfo, channelName, isDirectMessage, isGroupDm, isRoom, isRoomish, channelConfig, allowBotsMode, isBotMessage } = conversation;
|
|
3605
|
-
const authorization = await authorizeSlackInboundMessage({
|
|
3606
|
-
ctx,
|
|
3607
|
-
account,
|
|
3608
|
-
message,
|
|
3609
|
-
conversation,
|
|
3610
|
-
eventScope: opts.eventScope
|
|
3611
|
-
});
|
|
3612
|
-
if (!authorization) return null;
|
|
3613
|
-
const { senderId, allowFromLower } = authorization;
|
|
3614
|
-
const messageText = message.text ?? "";
|
|
3615
|
-
let resolvedSenderName = normalizeOptionalString(message.username);
|
|
3616
|
-
const resolveSenderName = async () => {
|
|
3617
|
-
if (resolvedSenderName) return resolvedSenderName;
|
|
3618
|
-
if (message.user) {
|
|
3619
|
-
const normalized = normalizeOptionalString((await ctx.resolveUserName(message.user, opts.eventScope))?.name);
|
|
3620
|
-
if (normalized) {
|
|
3621
|
-
resolvedSenderName = normalized;
|
|
3622
|
-
return resolvedSenderName;
|
|
3623
|
-
}
|
|
3624
|
-
}
|
|
3625
|
-
resolvedSenderName = message.user ?? message.bot_id ?? "unknown";
|
|
3626
|
-
return resolvedSenderName;
|
|
3627
|
-
};
|
|
3628
|
-
const mentionMetadata = collectSlackMentionMetadata(messageText);
|
|
3629
|
-
const { mentionedUserIds, mentionedSubteamIds, hasAnyMention } = mentionMetadata;
|
|
3630
|
-
const messageAssistantThreadContext = resolveSlackMessageAssistantThreadContext(message);
|
|
3631
|
-
const assistantContextLookupChannelId = messageAssistantThreadContext?.assistantChannelId ?? message.channel;
|
|
3632
|
-
const assistantContextLookupThreadTs = messageAssistantThreadContext?.threadTs ?? message.thread_ts ?? message.ts;
|
|
3633
|
-
const cachedAssistantThreadContext = isDirectMessage ? ctx.getSlackAssistantThreadContext(assistantContextLookupChannelId, assistantContextLookupThreadTs, opts.eventScope) : void 0;
|
|
3634
|
-
const restoredAssistantThreadContextPromise = isDirectMessage && !cachedAssistantThreadContext && !hasSlackAssistantThreadMetadata(messageAssistantThreadContext) ? restoreSlackAssistantThreadContextFromMetadata({
|
|
3635
|
-
ctx,
|
|
3636
|
-
message,
|
|
3637
|
-
eventScope: opts.eventScope
|
|
3638
|
-
}) : Promise.resolve(void 0);
|
|
3639
|
-
const { explicitlyMentionedBotUser, explicitlyMentionedBotSubteam, explicitlyMentioned } = await resolveSlackExplicitMentionState({
|
|
3640
|
-
ctx,
|
|
3641
|
-
messageText,
|
|
3642
|
-
mentionedUserIds,
|
|
3643
|
-
hasSubteamMention: mentionMetadata.hasSubteamMention,
|
|
3644
|
-
source: opts.source,
|
|
3645
|
-
eventScope: opts.eventScope
|
|
3646
|
-
});
|
|
3647
|
-
const channelRequireMention = channelConfig?.requireMention ?? ctx.defaultRequireMention ?? true;
|
|
3648
|
-
const channelChatType = isDirectMessage ? "direct" : isGroupDm ? "group" : "channel";
|
|
3649
|
-
const restoredAssistantThreadContext = await restoredAssistantThreadContextPromise;
|
|
3650
|
-
const assistantThreadContext = mergeSlackAssistantThreadContext(messageAssistantThreadContext, cachedAssistantThreadContext ?? restoredAssistantThreadContext);
|
|
3651
|
-
const assistantThreadContextToCache = messageAssistantThreadContext || restoredAssistantThreadContext ? assistantThreadContext : void 0;
|
|
3652
|
-
if (assistantThreadContextToCache) ctx.saveSlackAssistantThreadContext(assistantThreadContextToCache, opts.eventScope);
|
|
3653
|
-
const hasAgentViewMessageSignal = isDirectMessage && !opts.eventScope && !assistantThreadContext && isSlackAppContext(message.app_context);
|
|
3654
|
-
if (hasAgentViewMessageSignal) await ctx.recordSlackAgentView();
|
|
3655
|
-
const managedViewThreadTs = message.thread_ts;
|
|
3656
|
-
const isManagedViewRoot = isDirectMessage && !opts.eventScope && !assistantThreadContext && !message.parent_user_id && Boolean(managedViewThreadTs && message.ts && managedViewThreadTs === message.ts);
|
|
3657
|
-
if (isManagedViewRoot && managedViewThreadTs) await ctx.recordSlackManagedViewThread(message.channel, managedViewThreadTs);
|
|
3658
|
-
const hasManagedViewThread = isDirectMessage && !opts.eventScope && !assistantThreadContext && Boolean(managedViewThreadTs && await ctx.isSlackManagedViewThread(message.channel, managedViewThreadTs));
|
|
3659
|
-
const isAgentViewMessage = isDirectMessage && !opts.eventScope && !assistantThreadContext && (hasAgentViewMessageSignal || isManagedViewRoot || hasManagedViewThread || await ctx.isSlackAgentView());
|
|
3660
|
-
const agentViewThreadTs = isAgentViewMessage ? message.thread_ts ?? message.ts : void 0;
|
|
3661
|
-
const channelReplyToMode = channelConfig?.replyToMode ?? resolveSlackReplyToMode(account, channelChatType);
|
|
3662
|
-
const willImplicitlyThreadReply = isRoom && !channelRequireMention && channelReplyToMode !== "off";
|
|
3663
|
-
const seedTopLevelRoomThreadBySource = opts.source === "app_mention" || opts.wasMentioned === true || explicitlyMentioned || willImplicitlyThreadReply;
|
|
3664
|
-
let routing = resolveSlackRoutingContext({
|
|
3665
|
-
ctx,
|
|
3666
|
-
account,
|
|
3667
|
-
message,
|
|
3668
|
-
isDirectMessage,
|
|
3669
|
-
isGroupDm,
|
|
3670
|
-
isRoom,
|
|
3671
|
-
isRoomish,
|
|
3672
|
-
channelConfig,
|
|
3673
|
-
seedTopLevelRoomThread: seedTopLevelRoomThreadBySource,
|
|
3674
|
-
assistantThreadTs: assistantThreadContext?.threadTs,
|
|
3675
|
-
agentViewThreadTs,
|
|
3676
|
-
eventScope: opts.eventScope
|
|
3677
|
-
});
|
|
3678
|
-
let mentionCheckTranscript;
|
|
3679
|
-
const resolveWasMentioned = (mentionRegexes) => opts.wasMentioned ?? (!isDirectMessage && matchesMentionWithExplicit({
|
|
3680
|
-
text: messageText,
|
|
3681
|
-
mentionRegexes,
|
|
3682
|
-
explicit: {
|
|
3683
|
-
hasAnyMention,
|
|
3684
|
-
isExplicitlyMentioned: explicitlyMentioned,
|
|
3685
|
-
canResolveExplicit: Boolean(ctx.botUserId)
|
|
3686
|
-
},
|
|
3687
|
-
transcript: mentionCheckTranscript
|
|
3688
|
-
}));
|
|
3689
|
-
const buildPolicyMentionRegexes = (agentId) => resolveCachedMentionRegexes(ctx, agentId, {
|
|
3690
|
-
provider: "slack",
|
|
3691
|
-
conversationId: message.channel,
|
|
3692
|
-
providerPolicy: account.config.mentionPatterns
|
|
3693
|
-
});
|
|
3694
|
-
let mentionRegexes = buildPolicyMentionRegexes(routing.route.agentId);
|
|
3695
|
-
let wasMentioned = resolveWasMentioned(mentionRegexes);
|
|
3696
|
-
const hasBoundSession = Boolean(routing.runtimeBoundSessionKey || routing.configuredBindingSessionKey);
|
|
3697
|
-
let { route, runtimeBinding, replyToMode, threadContext, threadTs, isThreadReply, threadKeys, sessionKey, historyKey } = routing;
|
|
3698
|
-
const { configuredBinding, configuredBindingSessionKey } = routing;
|
|
3699
|
-
const isAssistantThreadMessage = Boolean(isDirectMessage && messageAssistantThreadContext);
|
|
3700
|
-
const forcedAssistantReplyThreadTs = Boolean(assistantThreadContext?.threadTs && (isThreadReply || isAssistantThreadMessage || replyToMode !== "off")) ? assistantThreadContext?.threadTs : void 0;
|
|
3701
|
-
const forcedReplyThreadTs = agentViewThreadTs ?? forcedAssistantReplyThreadTs;
|
|
3702
|
-
if (runtimeBinding && shouldLogVerbose()) logVerbose(`slack: routed via bound conversation ${runtimeBinding.conversation.conversationId} -> ${runtimeBinding.targetSessionKey}`);
|
|
3703
|
-
if (configuredBinding) {
|
|
3704
|
-
const ensured = await ensureConfiguredBindingRouteReady({
|
|
3705
|
-
cfg,
|
|
3706
|
-
bindingResolution: configuredBinding
|
|
3707
|
-
});
|
|
3708
|
-
if (ensured.ok) {
|
|
3709
|
-
if (shouldLogVerbose()) logVerbose(`slack: using configured ACP binding for ${configuredBinding.record.conversation.conversationId} -> ${configuredBindingSessionKey}`);
|
|
3710
|
-
} else {
|
|
3711
|
-
if (shouldLogVerbose()) logVerbose(`slack: configured ACP binding unavailable for ${configuredBinding.record.conversation.conversationId}: ${ensured.error}`);
|
|
3712
|
-
logInboundDrop({
|
|
3713
|
-
log: logVerbose,
|
|
3714
|
-
channel: "slack",
|
|
3715
|
-
reason: "configured ACP binding unavailable",
|
|
3716
|
-
target: configuredBinding.record.conversation.conversationId
|
|
3717
|
-
});
|
|
3718
|
-
return null;
|
|
3719
|
-
}
|
|
3720
|
-
}
|
|
3721
|
-
const senderNameForAuthPromise = ctx.allowNameMatching ? resolveSenderName().then((name) => ({
|
|
3722
|
-
ok: true,
|
|
3723
|
-
name
|
|
3724
|
-
}), (error) => ({
|
|
3725
|
-
ok: false,
|
|
3726
|
-
error
|
|
3727
|
-
})) : Promise.resolve({
|
|
3728
|
-
ok: true,
|
|
3729
|
-
name: void 0
|
|
3730
|
-
});
|
|
3731
|
-
let implicitMentionKinds = [];
|
|
3732
|
-
if (!isDirectMessage && ctx.botUserId && message.thread_ts && !wasMentioned) {
|
|
3733
|
-
const replyToBotKinds = implicitMentionKindWhen("reply_to_bot", message.parent_user_id === ctx.botUserId);
|
|
3734
|
-
implicitMentionKinds = replyToBotKinds.length > 0 ? replyToBotKinds : implicitMentionKindWhen("bot_thread_participant", await hasSlackThreadParticipationWithPersistence({
|
|
3735
|
-
accountId: account.accountId,
|
|
3736
|
-
channelId: message.channel,
|
|
3737
|
-
threadTs: message.thread_ts,
|
|
3738
|
-
...opts.eventScope ? { teamId: opts.eventScope.teamId } : {}
|
|
3739
|
-
}));
|
|
3740
|
-
}
|
|
3741
|
-
const recordDroppedHistory = async (reason) => {
|
|
3742
|
-
const pendingText = (message.text ?? "").trim();
|
|
3743
|
-
const historyMediaCandidate = buildSlackHistoryMediaCandidateMessage(message);
|
|
3744
|
-
const fallbackFile = message.files?.length ? `[Slack file: ${formatSlackFileReference(message.files[0])}]` : "";
|
|
3745
|
-
const pendingBody = pendingText || fallbackFile || (!fallbackFile && historyMediaCandidate ? "[Slack media attachment]" : "");
|
|
3746
|
-
const skippedThreadStarter = historyMediaCandidate && isThreadReply && threadTs ? await resolveSlackThreadStarter({
|
|
3747
|
-
channelId: message.channel,
|
|
3748
|
-
threadTs,
|
|
3749
|
-
client: slackClient,
|
|
3750
|
-
workspaceScope: threadStarterWorkspaceScope
|
|
3751
|
-
}) : null;
|
|
3752
|
-
const senderName = pendingBody ? await resolveSenderName() : void 0;
|
|
3753
|
-
await recordDroppedChannelInboundHistory({
|
|
3754
|
-
input: {
|
|
3755
|
-
id: message.ts ?? `${message.channel}:${Date.now()}`,
|
|
3756
|
-
timestamp: resolveSlackTimestampMs(message.ts),
|
|
3757
|
-
rawText: pendingBody,
|
|
3758
|
-
textForAgent: pendingBody,
|
|
3759
|
-
raw: message
|
|
3760
|
-
},
|
|
3761
|
-
admission: {
|
|
3762
|
-
kind: "drop",
|
|
3763
|
-
reason,
|
|
3764
|
-
recordHistory: true
|
|
3765
|
-
},
|
|
3766
|
-
preflight: {
|
|
3767
|
-
message: pendingBody ? {
|
|
3768
|
-
rawBody: pendingBody,
|
|
3769
|
-
body: pendingBody,
|
|
3770
|
-
bodyForAgent: pendingBody,
|
|
3771
|
-
senderLabel: senderName,
|
|
3772
|
-
envelopeFrom: senderName
|
|
3773
|
-
} : void 0,
|
|
3774
|
-
history: {
|
|
3775
|
-
key: historyKey,
|
|
3776
|
-
historyMap: ctx.channelHistories,
|
|
3777
|
-
limit: ctx.historyLimit,
|
|
3778
|
-
recordOnDrop: true,
|
|
3779
|
-
mediaLimit: SLACK_HISTORY_MEDIA_MAX_ATTACHMENTS,
|
|
3780
|
-
shouldRecord: opts.shouldRecordDroppedHistory
|
|
3781
|
-
},
|
|
3782
|
-
media: () => resolveSlackHistoryMediaForPendingRecord({
|
|
3783
|
-
ctx,
|
|
3784
|
-
message,
|
|
3785
|
-
isThreadReply,
|
|
3786
|
-
threadStarter: skippedThreadStarter,
|
|
3787
|
-
isBotMessage,
|
|
3788
|
-
eventScope: opts.eventScope
|
|
3789
|
-
})
|
|
3790
|
-
}
|
|
3791
|
-
});
|
|
3792
|
-
};
|
|
3793
|
-
let threadStarterPromise;
|
|
3794
|
-
const getThreadStarter = () => {
|
|
3795
|
-
threadStarterPromise ??= isThreadReply && threadTs ? resolveSlackThreadStarter({
|
|
3796
|
-
channelId: message.channel,
|
|
3797
|
-
threadTs,
|
|
3798
|
-
client: slackClient,
|
|
3799
|
-
workspaceScope: threadStarterWorkspaceScope
|
|
3800
|
-
}) : Promise.resolve(null);
|
|
3801
|
-
return threadStarterPromise;
|
|
3802
|
-
};
|
|
3803
|
-
const resolveMessageContent = (contentMessage, preloadedMedia) => getThreadStarter().then((threadStarter) => resolveSlackMessageContent({
|
|
3804
|
-
message: contentMessage,
|
|
3805
|
-
isThreadReply,
|
|
3806
|
-
threadStarter,
|
|
3807
|
-
isBotMessage,
|
|
3808
|
-
botToken: ctx.botToken,
|
|
3809
|
-
client: slackClient,
|
|
3810
|
-
mediaMaxBytes: ctx.mediaMaxBytes,
|
|
3811
|
-
resolveUserName: (userId) => ctx.resolveUserName(userId, opts.eventScope),
|
|
3812
|
-
preloadedMedia
|
|
3813
|
-
}));
|
|
3814
|
-
let preloadedDirectMedia;
|
|
3815
|
-
let messageContentPromise;
|
|
3816
|
-
const getMessageContent = () => {
|
|
3817
|
-
messageContentPromise ??= resolveMessageContent(message, preloadedDirectMedia);
|
|
3818
|
-
return messageContentPromise;
|
|
3819
|
-
};
|
|
3820
|
-
const senderNameForAuthResult = await senderNameForAuthPromise;
|
|
3821
|
-
if (!senderNameForAuthResult.ok) throw senderNameForAuthResult.error;
|
|
3822
|
-
const senderNameForAuth = senderNameForAuthResult.name;
|
|
3823
|
-
const allowTextCommands = shouldHandleTextCommands({
|
|
3824
|
-
cfg,
|
|
3825
|
-
surface: "slack"
|
|
3826
|
-
});
|
|
3827
|
-
const shouldRequireMention = isRoom ? channelConfig?.requireMention ?? ctx.defaultRequireMention : false;
|
|
3828
|
-
const implicitMentions = resolveChannelImplicitMentions({
|
|
3829
|
-
cfg,
|
|
3830
|
-
channel: "slack",
|
|
3831
|
-
accountId: account.accountId
|
|
3832
|
-
});
|
|
3833
|
-
if (message["_ambiguousThreadReply"]) {
|
|
3834
|
-
ctx.logger.info({
|
|
3835
|
-
channel: message.channel,
|
|
3836
|
-
ts: message.ts,
|
|
3837
|
-
parentUserId: message.parent_user_id
|
|
3838
|
-
}, "skipping ambiguous slack thread reply");
|
|
3839
|
-
return null;
|
|
3840
|
-
}
|
|
3841
|
-
let canDetectMention = Boolean(ctx.botUserId) || mentionRegexes.length > 0;
|
|
3842
|
-
const textForCommandDetection = stripSlackMentionsForCommandDetection(message.text ?? "");
|
|
3843
|
-
const hasControlCommandInMessage = hasControlCommand(textForCommandDetection, cfg);
|
|
3844
|
-
const hasAbortRequest = isAbortRequestText(textForCommandDetection);
|
|
3845
|
-
const channelUsersAllowlistConfigured = isRoom && Array.isArray(channelConfig?.users) && channelConfig.users.length > 0;
|
|
3846
|
-
const messageIngress = await resolveSlackCommandIngress({
|
|
3847
|
-
ctx,
|
|
3848
|
-
senderId,
|
|
3849
|
-
senderName: senderNameForAuth,
|
|
3850
|
-
channelType: conversation.resolvedChannelType ?? "channel",
|
|
3851
|
-
channelId: message.channel,
|
|
3852
|
-
ownerAllowFromLower: allowFromLower,
|
|
3853
|
-
channelUsers: isRoom ? channelConfig?.users : void 0,
|
|
3854
|
-
allowTextCommands,
|
|
3855
|
-
hasControlCommand: hasControlCommandInMessage,
|
|
3856
|
-
mentionFacts: {
|
|
3857
|
-
canDetectMention,
|
|
3858
|
-
wasMentioned,
|
|
3859
|
-
hasAnyMention,
|
|
3860
|
-
implicitMentionKinds
|
|
3861
|
-
},
|
|
3862
|
-
activation: {
|
|
3863
|
-
requireMention: shouldRequireMention,
|
|
3864
|
-
allowTextCommands,
|
|
3865
|
-
implicitMentions
|
|
3866
|
-
}
|
|
3867
|
-
});
|
|
3868
|
-
const senderGate = messageIngress.senderAccess.gate;
|
|
3869
|
-
if (isRoomish && senderGate?.allowed === false) {
|
|
3870
|
-
logVerbose(`Blocked unauthorized slack sender ${senderId} (not in sender allowlist)`);
|
|
3871
|
-
return null;
|
|
3872
|
-
}
|
|
3873
|
-
if (isRoom && isBotMessage && allowBotsMode !== "off" && !await authorizeSlackBotRoomMessage({
|
|
3874
|
-
ctx,
|
|
3875
|
-
channelId: message.channel,
|
|
3876
|
-
senderId,
|
|
3877
|
-
senderName: senderNameForAuth,
|
|
3878
|
-
channelUsers: channelConfig?.users,
|
|
3879
|
-
allowFromLower,
|
|
3880
|
-
eventScope: opts.eventScope
|
|
3881
|
-
})) return null;
|
|
3882
|
-
const threadContextAllowFromLower = isRoom ? channelUsersAllowlistConfigured ? normalizeAllowListLower(channelConfig?.users) : [] : isDirectMessage ? allowFromLower : [];
|
|
3883
|
-
const contextVisibilityMode = resolveChannelContextVisibilityMode({
|
|
3884
|
-
cfg: ctx.cfg,
|
|
3885
|
-
channel: "slack",
|
|
3886
|
-
accountId: account.accountId
|
|
3887
|
-
});
|
|
3888
|
-
const commandAuthorized = messageIngress.commandAccess.authorized;
|
|
3889
|
-
if (isRoomish && messageIngress.commandAccess.shouldBlockControlCommand) {
|
|
3890
|
-
logInboundDrop({
|
|
3891
|
-
log: logVerbose,
|
|
3892
|
-
channel: "slack",
|
|
3893
|
-
reason: "control command (unauthorized)",
|
|
3894
|
-
target: senderId
|
|
3895
|
-
});
|
|
3896
|
-
return null;
|
|
3897
|
-
}
|
|
3898
|
-
const canSeedMentionedRoomThread = !seedTopLevelRoomThreadBySource && isRoom && !routing.isThreadReply && !hasBoundSession;
|
|
3899
|
-
let seededMentionRouting;
|
|
3900
|
-
const getSeededMentionRouting = () => {
|
|
3901
|
-
seededMentionRouting ??= resolveSlackRoutingContext({
|
|
3902
|
-
ctx,
|
|
3903
|
-
account,
|
|
3904
|
-
message,
|
|
3905
|
-
isDirectMessage,
|
|
3906
|
-
isGroupDm,
|
|
3907
|
-
isRoom,
|
|
3908
|
-
isRoomish,
|
|
3909
|
-
channelConfig,
|
|
3910
|
-
seedTopLevelRoomThread: true,
|
|
3911
|
-
assistantThreadTs: assistantThreadContext?.threadTs,
|
|
3912
|
-
agentViewThreadTs,
|
|
3913
|
-
eventScope: opts.eventScope
|
|
3914
|
-
});
|
|
3915
|
-
return seededMentionRouting;
|
|
3916
|
-
};
|
|
3917
|
-
let preflightAudioTranscript;
|
|
3918
|
-
let preflightAudioMedia;
|
|
3919
|
-
const preflightAudioFile = findCaptionlessSlackAudioFile(message);
|
|
3920
|
-
if (isRoom && !isBotMessage && shouldRequireMention && cfg.tools?.media?.audio?.enabled !== false && messageIngress.activationAccess.shouldSkip && mentionRegexes.length > 0 && Boolean(preflightAudioFile) && preflightAudioFile) {
|
|
3921
|
-
const preflightRouting = canSeedMentionedRoomThread ? getSeededMentionRouting() : routing;
|
|
3922
|
-
const preflightMedia = (await resolveMessageContent({
|
|
3923
|
-
...message,
|
|
3924
|
-
files: [preflightAudioFile],
|
|
3925
|
-
attachments: void 0,
|
|
3926
|
-
blocks: void 0
|
|
3927
|
-
}))?.effectiveDirectMedia;
|
|
3928
|
-
const downloadedAudioMedia = preflightMedia?.[0];
|
|
3929
|
-
if (downloadedAudioMedia) preloadedDirectMedia = /* @__PURE__ */ new Map([[preflightAudioFile, downloadedAudioMedia]]);
|
|
3930
|
-
const preflightResult = preflightMedia ? await resolveSlackPreflightAudioTranscript({
|
|
3931
|
-
media: preflightMedia,
|
|
3932
|
-
cfg,
|
|
3933
|
-
accountId: account.accountId,
|
|
3934
|
-
originatingTo: `channel:${message.channel}`,
|
|
3935
|
-
sessionKey: preflightRouting.sessionKey,
|
|
3936
|
-
messageThreadId: preflightRouting.threadContext.messageThreadId
|
|
3937
|
-
}) : null;
|
|
3938
|
-
if (preflightResult) {
|
|
3939
|
-
mentionCheckTranscript = preflightResult.transcript;
|
|
3940
|
-
wasMentioned = resolveWasMentioned(mentionRegexes);
|
|
3941
|
-
if (wasMentioned) {
|
|
3942
|
-
preflightAudioTranscript = preflightResult.transcript;
|
|
3943
|
-
preflightAudioMedia = preflightMedia?.[preflightResult.mediaIndex];
|
|
3944
|
-
}
|
|
3945
|
-
}
|
|
3946
|
-
if (!preflightAudioTranscript) {
|
|
3947
|
-
await discardSlackPreflightMedia(preflightMedia);
|
|
3948
|
-
preloadedDirectMedia = void 0;
|
|
3949
|
-
}
|
|
3950
|
-
}
|
|
3951
|
-
if (canSeedMentionedRoomThread && wasMentioned) {
|
|
3952
|
-
routing = getSeededMentionRouting();
|
|
3953
|
-
mentionRegexes = buildPolicyMentionRegexes(routing.route.agentId);
|
|
3954
|
-
wasMentioned = resolveWasMentioned(mentionRegexes);
|
|
3955
|
-
({route, runtimeBinding, replyToMode, threadContext, threadTs, isThreadReply, threadKeys, sessionKey, historyKey} = routing);
|
|
3956
|
-
canDetectMention = Boolean(ctx.botUserId) || mentionRegexes.length > 0;
|
|
3957
|
-
}
|
|
3958
|
-
if (preflightAudioTranscript && !wasMentioned) {
|
|
3959
|
-
await discardSlackPreflightMedia(preloadedDirectMedia ? [...preloadedDirectMedia.values()] : void 0);
|
|
3960
|
-
preloadedDirectMedia = void 0;
|
|
3961
|
-
preflightAudioTranscript = void 0;
|
|
3962
|
-
preflightAudioMedia = void 0;
|
|
3963
|
-
}
|
|
3964
|
-
const directThreadRoutedToDmSession = !assistantThreadContext && !agentViewThreadTs && isDirectMessage && isThreadReply && threadTs && runtimeBinding?.conversation.conversationId !== threadTs;
|
|
3965
|
-
const mentionDecision = resolveInboundMentionDecision({
|
|
3966
|
-
facts: {
|
|
3967
|
-
canDetectMention,
|
|
3968
|
-
wasMentioned,
|
|
3969
|
-
hasAnyMention,
|
|
3970
|
-
implicitMentionKinds
|
|
3971
|
-
},
|
|
3972
|
-
policy: {
|
|
3973
|
-
isGroup: isRoom,
|
|
3974
|
-
requireMention: shouldRequireMention,
|
|
3975
|
-
allowTextCommands,
|
|
3976
|
-
hasControlCommand: hasControlCommandInMessage,
|
|
3977
|
-
commandAuthorized,
|
|
3978
|
-
implicitMentions
|
|
3979
|
-
}
|
|
3980
|
-
});
|
|
3981
|
-
const effectiveWasMentioned = mentionDecision.effectiveWasMentioned;
|
|
3982
|
-
const shouldBypassMention = mentionDecision.shouldBypassMention;
|
|
3983
|
-
const matchedImplicitMentionKinds = mentionDecision.matchedImplicitMentionKinds;
|
|
3984
|
-
const mentionSource = resolveSlackMentionSource({
|
|
3985
|
-
explicitBotMention: explicitlyMentionedBotUser || opts.source === "app_mention",
|
|
3986
|
-
explicitSubteamMention: explicitlyMentionedBotSubteam,
|
|
3987
|
-
matchedImplicitMentionKinds,
|
|
3988
|
-
shouldBypassMention,
|
|
3989
|
-
wasMentioned
|
|
3990
|
-
});
|
|
3991
|
-
if (isBotMessage && allowBotsMode === "mentions") {
|
|
3992
|
-
if (!(isDirectMessage || effectiveWasMentioned || shouldBypassMention)) {
|
|
3993
|
-
logVerbose("slack: drop bot message (allowBots=mentions, missing mention)");
|
|
3994
|
-
return null;
|
|
3995
|
-
}
|
|
3996
|
-
}
|
|
3997
|
-
if (isRoom && shouldRequireMention && !canDetectMention && !effectiveWasMentioned) {
|
|
3998
|
-
ctx.logger.info({
|
|
3999
|
-
channel: message.channel,
|
|
4000
|
-
reason: "mention-detection-unavailable"
|
|
4001
|
-
}, "skipping channel message");
|
|
4002
|
-
await recordDroppedHistory("slack-mention-detection-unavailable");
|
|
4003
|
-
return null;
|
|
4004
|
-
}
|
|
4005
|
-
const ignoreOtherMentions = channelConfig?.ignoreOtherMentions ?? false;
|
|
4006
|
-
if (isRoom && ignoreOtherMentions && Boolean(ctx.botUserId) && hasAnyMention && !wasMentioned) {
|
|
4007
|
-
logInboundDrop({
|
|
4008
|
-
log: logVerbose,
|
|
4009
|
-
channel: "slack",
|
|
4010
|
-
reason: "other-mention",
|
|
4011
|
-
target: senderId
|
|
4012
|
-
});
|
|
4013
|
-
await recordDroppedHistory("slack-other-mention");
|
|
4014
|
-
return null;
|
|
4015
|
-
}
|
|
4016
|
-
if (isRoom && shouldRequireMention && mentionDecision.shouldSkip) {
|
|
4017
|
-
ctx.logger.info({
|
|
4018
|
-
channel: message.channel,
|
|
4019
|
-
reason: "no-mention"
|
|
4020
|
-
}, "skipping channel message");
|
|
4021
|
-
await recordDroppedHistory("slack-no-mention");
|
|
4022
|
-
return null;
|
|
4023
|
-
}
|
|
4024
|
-
const chatType = resolveSlackChatType(conversation.resolvedChannelType);
|
|
4025
|
-
const inboundEventKind = classifyChannelInboundEvent({
|
|
4026
|
-
conversation: { kind: chatType },
|
|
4027
|
-
unmentionedGroupPolicy: resolveUnmentionedGroupInboundPolicy({
|
|
4028
|
-
cfg,
|
|
4029
|
-
agentId: route.agentId
|
|
4030
|
-
}),
|
|
4031
|
-
wasMentioned: effectiveWasMentioned,
|
|
4032
|
-
hasControlCommand: hasControlCommandInMessage,
|
|
4033
|
-
hasAbortRequest
|
|
4034
|
-
});
|
|
4035
|
-
const threadStarter = await getThreadStarter();
|
|
4036
|
-
const resolvedMessageContent = await getMessageContent();
|
|
4037
|
-
if (!resolvedMessageContent) return null;
|
|
4038
|
-
const { rawBody, effectiveDirectMedia } = resolvedMessageContent;
|
|
4039
|
-
const bodyForAgent = preflightAudioTranscript ? formatSlackAudioTranscriptForAgent({
|
|
4040
|
-
transcript: preflightAudioTranscript,
|
|
4041
|
-
rawBody
|
|
4042
|
-
}) : rawBody;
|
|
4043
|
-
const ackReaction = resolveAckReaction(cfg, route.agentId, {
|
|
4044
|
-
channel: "slack",
|
|
4045
|
-
accountId: account.accountId
|
|
4046
|
-
});
|
|
4047
|
-
const ackReactionValue = ackReaction ?? "";
|
|
4048
|
-
const sourceRepliesAreToolOnly = resolveChannelMessageSourceReplyDeliveryMode({
|
|
4049
|
-
cfg,
|
|
4050
|
-
ctx: {
|
|
4051
|
-
ChatType: chatType,
|
|
4052
|
-
InboundEventKind: inboundEventKind
|
|
4053
|
-
}
|
|
4054
|
-
}) === "message_tool_only";
|
|
4055
|
-
const statusReactionsExplicitlyEnabled = cfg.messages?.statusReactions?.enabled === true;
|
|
4056
|
-
const isRoomEvent = inboundEventKind === "room_event";
|
|
4057
|
-
const shouldAckReaction$1 = () => Boolean(ackReaction && shouldAckReaction({
|
|
4058
|
-
scope: ctx.ackReactionScope,
|
|
4059
|
-
inboundEventKind,
|
|
4060
|
-
isDirect: isDirectMessage,
|
|
4061
|
-
isGroup: isRoomish,
|
|
4062
|
-
isMentionableGroup: isRoom,
|
|
4063
|
-
canDetectMention,
|
|
4064
|
-
effectiveWasMentioned,
|
|
4065
|
-
shouldBypassMention
|
|
4066
|
-
}));
|
|
4067
|
-
const ackReactionMessageTs = message.ts;
|
|
4068
|
-
const allowToolOnlyStatusReaction = statusReactionsExplicitlyEnabled && (effectiveWasMentioned || shouldBypassMention);
|
|
4069
|
-
const shouldSendAckReaction = shouldAckReaction$1() && (!sourceRepliesAreToolOnly || allowToolOnlyStatusReaction || isRoomEvent);
|
|
4070
|
-
const statusReactionsWillHandle = Boolean(ackReactionMessageTs) && !isRoomEvent && statusReactionsExplicitlyEnabled && shouldSendAckReaction;
|
|
4071
|
-
const ackReactionPromise = !statusReactionsWillHandle && shouldSendAckReaction && ackReactionMessageTs && ackReactionValue ? reactSlackMessage(message.channel, ackReactionMessageTs, ackReactionValue, {
|
|
4072
|
-
token: ctx.botToken,
|
|
4073
|
-
client: slackClient
|
|
4074
|
-
}).then(() => true, (err) => {
|
|
4075
|
-
logVerbose(`slack react failed for channel ${message.channel}: ${formatSlackError(err)}`);
|
|
4076
|
-
return false;
|
|
4077
|
-
}) : statusReactionsWillHandle ? Promise.resolve(true) : null;
|
|
4078
|
-
const roomLabel = channelName ? `#${channelName}` : `#${message.channel}`;
|
|
4079
|
-
const senderName = await resolveSenderName();
|
|
4080
|
-
const preview = truncateUtf16Safe(bodyForAgent.replace(/\s+/g, " "), 160);
|
|
4081
|
-
const inboundLabel = isDirectMessage ? `Slack DM from ${senderName}` : `Slack message in ${roomLabel} from ${senderName}`;
|
|
4082
|
-
const slackFrom = isDirectMessage ? `slack:${message.user}` : isRoom ? `slack:channel:${message.channel}` : `slack:group:${message.channel}`;
|
|
4083
|
-
enqueueSystemEvent(inboundLabel, {
|
|
4084
|
-
sessionKey,
|
|
4085
|
-
contextKey: `slack:message:${message.channel}:${message.ts ?? "unknown"}`
|
|
4086
|
-
});
|
|
4087
|
-
const envelopeFrom = resolveConversationLabel$1({
|
|
4088
|
-
ChatType: chatType,
|
|
4089
|
-
SenderName: senderName,
|
|
4090
|
-
GroupSubject: isRoomish ? roomLabel : void 0,
|
|
4091
|
-
From: slackFrom
|
|
4092
|
-
}) ?? (isDirectMessage ? senderName : roomLabel);
|
|
4093
|
-
const threadInfo = isThreadReply && threadTs ? ` thread_ts: ${threadTs}${message.parent_user_id ? ` parent_user_id: ${message.parent_user_id}` : ""}` : "";
|
|
4094
|
-
const textWithId = `${bodyForAgent}\n[slack message id: ${message.ts} channel: ${message.channel}${threadInfo}]`;
|
|
4095
|
-
const storePath = resolveStorePath(ctx.cfg.session?.store, { agentId: route.agentId });
|
|
4096
|
-
const envelopeOptions = resolveEnvelopeFormatOptions(ctx.cfg);
|
|
4097
|
-
const previousTimestamp = readSessionUpdatedAt({
|
|
4098
|
-
storePath,
|
|
4099
|
-
sessionKey
|
|
4100
|
-
});
|
|
4101
|
-
if (opts.source === "app_mention" && !ctx.botUserId && message.ts) {
|
|
4102
|
-
const pendingHistory = ctx.channelHistories.get(historyKey);
|
|
4103
|
-
if (pendingHistory) ctx.channelHistories.set(historyKey, pendingHistory.filter((entry) => entry.messageId !== message.ts));
|
|
4104
|
-
}
|
|
4105
|
-
const channelHistory = createChannelHistoryWindow({ historyMap: ctx.channelHistories });
|
|
4106
|
-
const dmHistoryLimit = isDirectMessage ? resolveSlackDmHistoryLimit({
|
|
4107
|
-
account,
|
|
4108
|
-
userId: message.user,
|
|
4109
|
-
defaultLimit: ctx.dmHistoryLimit
|
|
4110
|
-
}) : 0;
|
|
4111
|
-
let combinedBody = formatInboundEnvelope({
|
|
4112
|
-
channel: "Slack",
|
|
4113
|
-
from: envelopeFrom,
|
|
4114
|
-
timestamp: resolveSlackTimestampMs(message.ts),
|
|
4115
|
-
body: textWithId,
|
|
4116
|
-
chatType,
|
|
4117
|
-
sender: {
|
|
4118
|
-
name: senderName,
|
|
4119
|
-
id: senderId
|
|
4120
|
-
},
|
|
4121
|
-
previousTimestamp,
|
|
4122
|
-
envelope: envelopeOptions
|
|
4123
|
-
});
|
|
4124
|
-
const dmHistoryContext = isDirectMessage && !assistantThreadContext && !agentViewThreadTs && !isThreadReply && dmHistoryLimit > 0 && !previousTimestamp ? await resolveSlackDmHistoryContext({
|
|
4125
|
-
ctx,
|
|
4126
|
-
channelId: message.channel,
|
|
4127
|
-
currentMessageTs: message.ts,
|
|
4128
|
-
limit: dmHistoryLimit,
|
|
4129
|
-
envelopeOptions,
|
|
4130
|
-
eventScope: opts.eventScope
|
|
4131
|
-
}) : {
|
|
4132
|
-
body: void 0,
|
|
4133
|
-
inboundHistory: void 0
|
|
4134
|
-
};
|
|
4135
|
-
if (dmHistoryContext.body) combinedBody = `${dmHistoryContext.body}\n\n${combinedBody}`;
|
|
4136
|
-
if (isRoomish && ctx.historyLimit > 0) combinedBody = channelHistory.buildPendingContext({
|
|
4137
|
-
historyKey,
|
|
4138
|
-
limit: ctx.historyLimit,
|
|
4139
|
-
currentMessage: combinedBody,
|
|
4140
|
-
formatEntry: (entry) => formatInboundEnvelope({
|
|
4141
|
-
channel: "Slack",
|
|
4142
|
-
from: roomLabel,
|
|
4143
|
-
timestamp: entry.timestamp,
|
|
4144
|
-
body: `${entry.body}${entry.messageId ? ` [id:${entry.messageId} channel:${message.channel}]` : ""}`,
|
|
4145
|
-
chatType: "channel",
|
|
4146
|
-
senderLabel: entry.sender,
|
|
4147
|
-
envelope: envelopeOptions
|
|
4148
|
-
})
|
|
4149
|
-
});
|
|
4150
|
-
const slackTo = isDirectMessage ? `user:${message.user}` : `channel:${message.channel}`;
|
|
4151
|
-
const { channelMetadata, groupSystemPrompt } = resolveSlackRoomContextHints({
|
|
4152
|
-
isRoomish,
|
|
4153
|
-
channelInfo,
|
|
4154
|
-
channelConfig
|
|
4155
|
-
});
|
|
4156
|
-
const { threadStarterBody, threadHistoryBody, shouldSeedInitialThreadContext, threadLabel, threadStarterMedia } = await resolveSlackThreadContextData({
|
|
4157
|
-
ctx,
|
|
4158
|
-
account,
|
|
4159
|
-
message,
|
|
4160
|
-
isThreadReply,
|
|
4161
|
-
threadTs,
|
|
4162
|
-
threadStarter,
|
|
4163
|
-
roomLabel,
|
|
4164
|
-
storePath,
|
|
4165
|
-
sessionKey,
|
|
4166
|
-
forceInitialHistory: Boolean(directThreadRoutedToDmSession),
|
|
4167
|
-
allowFromLower: threadContextAllowFromLower,
|
|
4168
|
-
allowNameMatching: ctx.allowNameMatching,
|
|
4169
|
-
contextVisibilityMode,
|
|
4170
|
-
envelopeOptions,
|
|
4171
|
-
effectiveDirectMedia,
|
|
4172
|
-
eventScope: opts.eventScope
|
|
4173
|
-
});
|
|
4174
|
-
const effectiveMedia = effectiveDirectMedia ?? threadStarterMedia;
|
|
4175
|
-
const inboundMedia = await toInboundMediaFactsWithMetadata(effectiveMedia, { transcribed: (entry) => effectiveMedia === effectiveDirectMedia && entry === preflightAudioMedia });
|
|
4176
|
-
const inboundHistory = isRoomish && ctx.historyLimit > 0 ? channelHistory.buildInboundHistory({
|
|
4177
|
-
historyKey,
|
|
4178
|
-
limit: ctx.historyLimit
|
|
4179
|
-
}) : dmHistoryContext.inboundHistory;
|
|
4180
|
-
const commandBody = textForCommandDetection.trim();
|
|
4181
|
-
const supplementalThreadHistoryBody = directThreadRoutedToDmSession && !threadHistoryBody ? threadStarterBody : threadHistoryBody;
|
|
4182
|
-
const effectiveMessageThreadId = assistantThreadContext?.threadTs ?? agentViewThreadTs ?? threadContext.messageThreadId;
|
|
4183
|
-
const agentContextEntities = isAgentViewMessage ? normalizeSlackAppContextEntities(message.app_context) : [];
|
|
4184
|
-
const ctxPayload = buildChannelInboundEventContext({
|
|
4185
|
-
channel: "slack",
|
|
4186
|
-
accountId: route.accountId,
|
|
4187
|
-
messageId: threadContext.messageTs,
|
|
4188
|
-
timestamp: resolveSlackTimestampMs(message.ts),
|
|
4189
|
-
from: slackFrom,
|
|
4190
|
-
sender: {
|
|
4191
|
-
id: senderId,
|
|
4192
|
-
name: senderName,
|
|
4193
|
-
displayLabel: senderName,
|
|
4194
|
-
isBot: isBotMessage || void 0
|
|
4195
|
-
},
|
|
4196
|
-
conversation: {
|
|
4197
|
-
kind: chatType,
|
|
4198
|
-
id: message.channel,
|
|
4199
|
-
label: envelopeFrom,
|
|
4200
|
-
spaceId: opts.eventScope?.teamId || ctx.teamId || void 0,
|
|
4201
|
-
threadId: directThreadRoutedToDmSession ? void 0 : effectiveMessageThreadId,
|
|
4202
|
-
nativeChannelId: message.channel
|
|
4203
|
-
},
|
|
4204
|
-
route: {
|
|
4205
|
-
agentId: route.agentId,
|
|
4206
|
-
dmScope: route.dmScope,
|
|
4207
|
-
accountId: route.accountId,
|
|
4208
|
-
routeSessionKey: sessionKey,
|
|
4209
|
-
parentSessionKey: threadKeys.parentSessionKey
|
|
4210
|
-
},
|
|
4211
|
-
reply: {
|
|
4212
|
-
to: slackTo,
|
|
4213
|
-
replyToId: threadContext.replyToId,
|
|
4214
|
-
messageThreadId: directThreadRoutedToDmSession ? void 0 : effectiveMessageThreadId,
|
|
4215
|
-
nativeChannelId: message.channel
|
|
4216
|
-
},
|
|
4217
|
-
message: {
|
|
4218
|
-
inboundEventKind,
|
|
4219
|
-
body: combinedBody,
|
|
4220
|
-
bodyForAgent,
|
|
4221
|
-
rawBody,
|
|
4222
|
-
commandBody,
|
|
4223
|
-
inboundHistory
|
|
4224
|
-
},
|
|
4225
|
-
sessionTranscript: { historyLimit: isRoomish ? ctx.historyLimit : dmHistoryLimit },
|
|
4226
|
-
access: {
|
|
4227
|
-
mentions: {
|
|
4228
|
-
canDetectMention: isRoomish,
|
|
4229
|
-
wasMentioned: effectiveWasMentioned,
|
|
4230
|
-
hasAnyMention: explicitlyMentioned || mentionedSubteamIds.length > 0,
|
|
4231
|
-
implicitMentionKinds: matchedImplicitMentionKinds,
|
|
4232
|
-
requireMention: shouldRequireMention,
|
|
4233
|
-
effectiveWasMentioned
|
|
4234
|
-
},
|
|
4235
|
-
commands: { authorized: commandAuthorized }
|
|
4236
|
-
},
|
|
4237
|
-
media: inboundMedia,
|
|
4238
|
-
supplemental: {
|
|
4239
|
-
thread: {
|
|
4240
|
-
starterBody: !directThreadRoutedToDmSession && shouldSeedInitialThreadContext ? threadStarterBody : void 0,
|
|
4241
|
-
historyBody: supplementalThreadHistoryBody,
|
|
4242
|
-
label: directThreadRoutedToDmSession ? void 0 : threadLabel
|
|
4243
|
-
},
|
|
4244
|
-
groupSystemPrompt
|
|
4245
|
-
},
|
|
4246
|
-
extra: {
|
|
4247
|
-
GroupSubject: isRoomish ? roomLabel : void 0,
|
|
4248
|
-
ChannelPromptContext: channelMetadata ? [channelMetadata] : void 0,
|
|
4249
|
-
ChannelStructuredContext: agentContextEntities.length > 0 ? [{
|
|
4250
|
-
label: "Slack active context",
|
|
4251
|
-
source: "slack",
|
|
4252
|
-
type: "active_view",
|
|
4253
|
-
payload: { entities: agentContextEntities }
|
|
4254
|
-
}] : void 0,
|
|
4255
|
-
TransportThreadId: directThreadRoutedToDmSession ? threadContext.messageThreadId : void 0,
|
|
4256
|
-
SlackAssistantThread: assistantThreadContext ? true : void 0,
|
|
4257
|
-
SlackAgentThread: agentViewThreadTs ? true : void 0,
|
|
4258
|
-
SlackAssistantThreadContextChannelId: assistantThreadContext?.channelId,
|
|
4259
|
-
SlackAssistantThreadContextTeamId: assistantThreadContext?.teamId,
|
|
4260
|
-
SlackAssistantThreadContextEnterpriseId: assistantThreadContext?.enterpriseId ?? void 0,
|
|
4261
|
-
Transcript: preflightAudioTranscript,
|
|
4262
|
-
IsFirstThreadTurn: isThreadReply && threadTs && !directThreadRoutedToDmSession && shouldSeedInitialThreadContext ? true : void 0,
|
|
4263
|
-
...buildSlackMentionContextPayload({
|
|
4264
|
-
isRoomish,
|
|
4265
|
-
effectiveWasMentioned,
|
|
4266
|
-
explicitlyMentioned,
|
|
4267
|
-
mentionedUserIds,
|
|
4268
|
-
mentionedSubteamIds,
|
|
4269
|
-
matchedImplicitMentionKinds,
|
|
4270
|
-
mentionSource
|
|
4271
|
-
})
|
|
4272
|
-
}
|
|
4273
|
-
});
|
|
4274
|
-
ctxPayload.ReplyToMode = replyToMode;
|
|
4275
|
-
if (isRoomish && !shouldRequireMention) channelHistory.record({
|
|
4276
|
-
historyKey,
|
|
4277
|
-
limit: ctx.historyLimit,
|
|
4278
|
-
entry: {
|
|
4279
|
-
sender: senderName,
|
|
4280
|
-
body: rawBody,
|
|
4281
|
-
timestamp: resolveSlackTimestampMs(message.ts),
|
|
4282
|
-
messageId: message.ts
|
|
4283
|
-
}
|
|
4284
|
-
});
|
|
4285
|
-
const pinnedMainDmOwner = isDirectMessage ? resolvePinnedMainDmOwnerFromAllowlist({
|
|
4286
|
-
dmScope: cfg.session?.dmScope,
|
|
4287
|
-
allowFrom: ctx.allowFrom,
|
|
4288
|
-
normalizeEntry: normalizeSlackAllowOwnerEntry
|
|
4289
|
-
}) : null;
|
|
4290
|
-
const replyTarget = isDirectMessage ? `channel:${message.channel}` : ctxPayload.To ?? void 0;
|
|
4291
|
-
if (!replyTarget) return null;
|
|
4292
|
-
if (preflightAudioTranscript) await sendSlackPreflightAudioTranscriptEcho({
|
|
4293
|
-
transcript: preflightAudioTranscript,
|
|
4294
|
-
cfg,
|
|
4295
|
-
accountId: account.accountId,
|
|
4296
|
-
originatingTo: `channel:${message.channel}`,
|
|
4297
|
-
messageThreadId: threadContext.messageThreadId
|
|
4298
|
-
});
|
|
4299
|
-
if (shouldLogVerbose()) logVerbose(`slack inbound: account=${route.accountId} agent=${route.agentId} channel=${message.channel} message_ts=${message.ts ?? "unknown"} thread_ts=${effectiveMessageThreadId ?? "none"} from=${slackFrom} chat=${chatType} chars=${rawBody.length}`);
|
|
4300
|
-
const updateLastRouteSessionKey = resolveInboundLastRouteSessionKey({
|
|
4301
|
-
route,
|
|
4302
|
-
sessionKey
|
|
4303
|
-
});
|
|
4304
|
-
return {
|
|
4305
|
-
ctx,
|
|
4306
|
-
account,
|
|
4307
|
-
message,
|
|
4308
|
-
...opts.relayIdentity ? { relayIdentity: opts.relayIdentity } : {},
|
|
4309
|
-
...opts.eventScope ? { eventScope: opts.eventScope } : {},
|
|
4310
|
-
route,
|
|
4311
|
-
channelConfig,
|
|
4312
|
-
replyTarget,
|
|
4313
|
-
ctxPayload,
|
|
4314
|
-
turn: {
|
|
4315
|
-
storePath,
|
|
4316
|
-
record: {
|
|
4317
|
-
updateLastRoute: isDirectMessage ? {
|
|
4318
|
-
sessionKey: updateLastRouteSessionKey,
|
|
4319
|
-
channel: "slack",
|
|
4320
|
-
to: `user:${message.user}`,
|
|
4321
|
-
accountId: route.accountId,
|
|
4322
|
-
threadId: effectiveMessageThreadId,
|
|
4323
|
-
mainDmOwnerPin: updateLastRouteSessionKey === route.mainSessionKey && pinnedMainDmOwner && message.user ? {
|
|
4324
|
-
ownerRecipient: pinnedMainDmOwner,
|
|
4325
|
-
senderRecipient: normalizeLowercaseStringOrEmpty(message.user),
|
|
4326
|
-
onSkip: ({ ownerRecipient, senderRecipient }) => {
|
|
4327
|
-
logVerbose(`slack: skip main-session last route for ${senderRecipient} (pinned owner ${ownerRecipient})`);
|
|
4328
|
-
}
|
|
4329
|
-
} : void 0
|
|
4330
|
-
} : void 0,
|
|
4331
|
-
onRecordError: (err) => {
|
|
4332
|
-
ctx.logger.warn({
|
|
4333
|
-
error: formatErrorMessage(err),
|
|
4334
|
-
storePath,
|
|
4335
|
-
sessionKey
|
|
4336
|
-
}, "failed updating session meta");
|
|
4337
|
-
}
|
|
4338
|
-
},
|
|
4339
|
-
history: isRoomish && shouldRequireMention ? {
|
|
4340
|
-
isGroup: true,
|
|
4341
|
-
historyKey,
|
|
4342
|
-
historyMap: ctx.channelHistories,
|
|
4343
|
-
limit: ctx.historyLimit
|
|
4344
|
-
} : void 0
|
|
4345
|
-
},
|
|
4346
|
-
replyToMode,
|
|
4347
|
-
...forcedReplyThreadTs ? { forcedReplyThreadTs } : {},
|
|
4348
|
-
...assistantThreadContext ? { slackMessageMetadata: buildSlackAssistantThreadMetadata(assistantThreadContext) } : {},
|
|
4349
|
-
requireMention: shouldRequireMention,
|
|
4350
|
-
isDirectMessage,
|
|
4351
|
-
isRoomish,
|
|
4352
|
-
historyKey,
|
|
4353
|
-
preview,
|
|
4354
|
-
ackReactionMessageTs,
|
|
4355
|
-
ackReactionValue,
|
|
4356
|
-
ackReactionPromise
|
|
4357
|
-
};
|
|
4358
|
-
}
|
|
4359
|
-
//#endregion
|
|
4360
|
-
export { dispatchPreparedSlackMessage, prepareSlackMessage };
|