@openclaw/discord 2026.8.1-beta.2 → 2026.8.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{account-inspect-CqzrH14k.js → account-inspect-BDfKyuvL.js} +1 -1
- package/dist/account-inspect-api.js +1 -1
- package/dist/{accounts-DJTf1LtA.js → accounts-CfQ-vSyf.js} +34 -1
- package/dist/action-runtime-api.js +1 -1
- package/dist/{activities-api-DS7vpdtp.js → activities-api-Dl-TOyOX.js} +134 -175
- package/dist/activities-api.js +1 -1
- package/dist/api.js +17 -17
- package/dist/{approval-handler.runtime-B6yEV79q.js → approval-handler.runtime-q4Zqo44V.js} +29 -106
- package/dist/{audit-Db-rlntl.js → audit-DgrvFPGt.js} +5 -5
- package/dist/{channel-CnnbJSt5.js → channel-BsQUalPw.js} +72 -50
- package/dist/{channel-actions.runtime-CLKrx6tr.js → channel-actions.runtime-UMGGIfSy.js} +31 -45
- package/dist/channel-config-api.js +1 -1
- package/dist/channel-plugin-api.js +1 -1
- package/dist/channel-type-CVLZyGYS.js +7 -0
- package/dist/{channel.setup-BFAO-V1P.js → channel.setup-rPs4dsk_.js} +5 -5
- package/dist/{outbound-session-route-DxLkrgKQ.js → components-Dk35LTf_.js} +34 -76
- package/dist/{config-schema-BgEskFAs.js → config-schema-CxPqtVI1.js} +46 -14
- package/dist/conversation-binding-route-BjvX4e35.js +43 -0
- package/dist/{directory-config-BVX7Cflc.js → directory-config-B7DY_pNG.js} +2 -2
- package/dist/directory-contract-api.js +1 -1
- package/dist/{directory-live-DGIGxpIo.js → directory-live-DuAXKkan.js} +3 -3
- package/dist/doctor-contract-api.js +2 -2
- package/dist/{doctor-BzC-TLnB.js → doctor-zQTtn6hm.js} +33 -12
- package/dist/{handle-action.guild-admin-BNVTUISF.js → handle-action.guild-admin-DZewwLr1.js} +9 -5
- package/dist/index.js +3 -4
- package/dist/ingress-identity-CzZKcPK8.js +60 -0
- package/dist/{message-handler-Unk_f10F.js → message-handler-C5By3yl5.js} +82 -6
- package/dist/{message-handler.preflight-C9zecxR9.js → message-handler.preflight-DrszWuHw.js} +44 -118
- package/dist/{message-handler.process-DWQ6UHHu.js → message-handler.process-DyFPDLCt.js} +205 -235
- package/dist/{message-utils-BSCPVgy0.js → message-text-Ca8M6TU8.js} +43 -42
- package/dist/{outbound-adapter-D9nRivT1.js → outbound-adapter-Dif8p481.js} +118 -91
- package/dist/{outbound-components-cTzwBJ60.js → outbound-components-wjv7yyAj.js} +5 -4
- package/dist/outbound-session-route-Bn4uXaoE.js +665 -0
- package/dist/owner-access-UlYi9t0M.js +107 -0
- package/dist/{pluralkit-DdiJ9KMK.js → pluralkit-9EuEN4UD.js} +1 -1
- package/dist/{probe-Bl-k5_Ku.js → probe-n6ZXxK8V.js} +1 -1
- package/dist/{probe.runtime-M9fREKvp.js → probe.runtime-CN4bdPfZ.js} +1 -1
- package/dist/{provider-DvSNb-2v.js → provider-LXiOcJrH.js} +887 -1350
- package/dist/{provider-session.runtime-BUEqD0rA.js → provider-session.runtime-DSNe7r2W.js} +3 -3
- package/dist/provider.runtime-DiInaDXO.js +2 -0
- package/dist/{realtime-session.runtime-C7wen-aF.js → realtime-session.runtime-DOViOIjY.js} +129 -134
- package/dist/{resolve-allowlist-common-D04lpEzb.js → resolve-allowlist-common-BLoYaxEG.js} +2 -2
- package/dist/{resolve-channels-Dm7jEeg6.js → resolve-channels-D2yl_2CN.js} +5 -4
- package/dist/{resolve-users-bktrCUUU.js → resolve-users-BLxfqajZ.js} +2 -2
- package/dist/{retry-CLpJcXXf.js → retry-DqHCW6PV.js} +187 -19
- package/dist/{runtime-DGsSyDTS.js → runtime-BYamRVPN.js} +89 -86
- package/dist/{runtime-DoHjckYm.js → runtime-DrxVBTtp.js} +9 -10
- package/dist/runtime-api.js +19 -25
- package/dist/{sdk-runtime-QpY8PvCh.js → sdk-runtime-6tfgYDjY.js} +57 -89
- package/dist/{secret-config-contract-B1akrlyY.js → secret-config-contract-B3i6WxV5.js} +53 -25
- package/dist/secret-contract-api.js +1 -1
- package/dist/{security-audit-jGnJF__m.js → security-audit-DKfK-iPY.js} +11 -12
- package/dist/security-audit-contract-api.js +1 -1
- package/dist/{security-audit.runtime-CPN0xFYz.js → security-audit.runtime-sKZyKgpx.js} +1 -1
- package/dist/{send-B7Q6Oc1I.js → send-UJHiAm4C.js} +82 -19
- package/dist/{send.components-iJyFXw9L.js → send.components-CrBJpGT_.js} +22 -39
- package/dist/{send.outbound-DS5tHwfR.js → send.outbound-D7JYmfm9.js} +77 -78
- package/dist/{send.shared-BmwFjW6T.js → send.shared-DZJ1akvQ.js} +136 -121
- package/dist/{sender-identity-QtalnCYv.js → sender-identity-BJtfyise.js} +1 -1
- package/dist/setup-plugin-api.js +1 -1
- package/dist/{shared-BIXIX6uJ.js → shared-Dii2HTn7.js} +41 -14
- package/dist/subagent-hooks-JyGrtQIl.js +49 -0
- package/dist/subagent-hooks-api.js +1 -6
- package/dist/{system-events-CTqDf6_s.js → system-events-BEmcj4xJ.js} +2 -2
- package/dist/{target-resolver-maOKSqO0.js → target-resolver-V-IYae6s.js} +3 -3
- package/dist/targets-CQp53cGj.js +3 -0
- package/dist/{thread-bindings-3L8p82GV.js → thread-bindings-DvYP79fy.js} +28 -26
- package/dist/{thread-bindings.manager-DCIH6WDC.js → thread-bindings.manager-Clm77DBM.js} +11 -14
- package/dist/{thread-bindings.session-updates-bJ2KQFY6.js → thread-bindings.session-updates-CJb-BpPL.js} +1 -1
- package/dist/{thread-bindings.state-aeV8HNgV.js → thread-bindings.state-D8OMdk4O.js} +1 -1
- package/dist/threading-CXuu_7o9.js +478 -0
- package/dist/transcripts-source-BLEMH_yi.js +270 -0
- package/dist/transcripts-source-api.js +7 -2
- package/dist/{typing-CS-nNVoe.js → typing-B9snnwMe.js} +1 -1
- package/dist/{voice-runtime-BEdqNcST.js → voice-runtime-DY6_o73o.js} +250 -150
- package/node_modules/@discord/embedded-app-sdk/node_modules/uuid/README.md +19 -19
- package/node_modules/@discord/embedded-app-sdk/node_modules/uuid/dist/v1.js +7 -3
- package/node_modules/@discord/embedded-app-sdk/node_modules/uuid/dist/v7.js +5 -2
- package/node_modules/@discord/embedded-app-sdk/node_modules/uuid/dist-node/v1.js +7 -3
- package/node_modules/@discord/embedded-app-sdk/node_modules/uuid/dist-node/v7.js +5 -2
- package/node_modules/@discord/embedded-app-sdk/node_modules/uuid/package.json +4 -3
- package/node_modules/@discordjs/voice/node_modules/@types/node/README.md +1 -1
- package/node_modules/@discordjs/voice/node_modules/@types/node/child_process.d.ts +0 -1
- package/node_modules/@discordjs/voice/node_modules/@types/node/crypto.d.ts +6 -6
- package/node_modules/@discordjs/voice/node_modules/@types/node/dns/promises.d.ts +5 -5
- package/node_modules/@discordjs/voice/node_modules/@types/node/dns.d.ts +5 -5
- package/node_modules/@discordjs/voice/node_modules/@types/node/fs.d.ts +7 -0
- package/node_modules/@discordjs/voice/node_modules/@types/node/http.d.ts +30 -0
- package/node_modules/@discordjs/voice/node_modules/@types/node/http2.d.ts +4 -4
- package/node_modules/@discordjs/voice/node_modules/@types/node/os.d.ts +30 -30
- package/node_modules/@discordjs/voice/node_modules/@types/node/package.json +2 -2
- package/node_modules/@discordjs/voice/node_modules/@types/node/perf_hooks.d.ts +2 -1
- package/node_modules/@discordjs/voice/node_modules/@types/node/process.d.ts +42 -43
- package/node_modules/@discordjs/voice/node_modules/@types/node/quic.d.ts +1049 -84
- package/node_modules/@discordjs/voice/node_modules/@types/node/sqlite.d.ts +14 -1
- package/node_modules/@discordjs/voice/node_modules/@types/node/stream/iter.d.ts +3 -2
- package/node_modules/@discordjs/voice/node_modules/@types/node/test.d.ts +61 -0
- package/node_modules/@discordjs/voice/node_modules/@types/node/v8.d.ts +20 -23
- package/node_modules/discord-api-types/CHANGELOG.md +8 -0
- package/node_modules/discord-api-types/package.json +4 -4
- package/node_modules/discord-api-types/payloads/v10/channel.d.ts +2 -2
- package/node_modules/discord-api-types/payloads/v10/channel.d.ts.map +1 -1
- package/node_modules/discord-api-types/payloads/v10/gateway.d.ts +4 -0
- package/node_modules/discord-api-types/payloads/v10/gateway.d.ts.map +1 -1
- package/node_modules/discord-api-types/payloads/v10/gateway.js.map +1 -1
- package/node_modules/discord-api-types/payloads/v10/message.d.ts +4 -1
- package/node_modules/discord-api-types/payloads/v10/message.d.ts.map +1 -1
- package/node_modules/discord-api-types/payloads/v10/message.js +1 -0
- package/node_modules/discord-api-types/payloads/v10/message.js.map +1 -1
- package/node_modules/discord-api-types/payloads/v9/channel.d.ts +2 -2
- package/node_modules/discord-api-types/payloads/v9/channel.d.ts.map +1 -1
- package/node_modules/discord-api-types/payloads/v9/gateway.d.ts +4 -0
- package/node_modules/discord-api-types/payloads/v9/gateway.d.ts.map +1 -1
- package/node_modules/discord-api-types/payloads/v9/gateway.js.map +1 -1
- package/node_modules/discord-api-types/payloads/v9/message.d.ts +4 -1
- package/node_modules/discord-api-types/payloads/v9/message.d.ts.map +1 -1
- package/node_modules/discord-api-types/payloads/v9/message.js +1 -0
- package/node_modules/discord-api-types/payloads/v9/message.js.map +1 -1
- package/node_modules/typebox/build/format/date.d.mts +1 -1
- package/node_modules/typebox/build/format/date.mjs +1 -1
- package/node_modules/typebox/build/format/date_time.d.mts +2 -2
- package/node_modules/typebox/build/format/date_time.mjs +3 -3
- package/node_modules/typebox/build/format/email.d.mts +1 -1
- package/node_modules/typebox/build/format/email.mjs +2 -2
- package/node_modules/typebox/build/format/hostname.mjs +2 -10
- package/node_modules/typebox/build/format/idn_email.d.mts +1 -1
- package/node_modules/typebox/build/format/idn_email.mjs +3 -3
- package/node_modules/typebox/build/format/idn_hostname.d.mts +1 -0
- package/node_modules/typebox/build/format/idn_hostname.mjs +3 -11
- package/node_modules/typebox/build/format/idna/format/bidi.d.mts +3 -0
- package/node_modules/typebox/build/format/idna/format/bidi.mjs +98 -0
- package/node_modules/typebox/build/format/idna/format/puny.d.mts +3 -0
- package/node_modules/typebox/build/format/idna/format/puny.mjs +144 -0
- package/node_modules/typebox/build/format/idna/hostname.d.mts +1 -0
- package/node_modules/typebox/build/format/idna/hostname.mjs +16 -0
- package/node_modules/typebox/build/format/idna/idn-hostname.d.mts +1 -0
- package/node_modules/typebox/build/format/idna/idn-hostname.mjs +23 -0
- package/node_modules/typebox/build/format/idna/index.d.mts +2 -0
- package/node_modules/typebox/build/format/idna/index.mjs +2 -0
- package/node_modules/typebox/build/format/idna/label/ascii.d.mts +1 -0
- package/node_modules/typebox/build/format/idna/label/ascii.mjs +9 -0
- package/node_modules/typebox/build/format/idna/label/puny.d.mts +1 -0
- package/node_modules/typebox/build/format/idna/label/puny.mjs +28 -0
- package/node_modules/typebox/build/format/idna/label/unicode.d.mts +1 -0
- package/node_modules/typebox/build/format/idna/label/unicode.mjs +106 -0
- package/node_modules/typebox/build/format/idna/pattern/pattern.d.mts +30 -0
- package/node_modules/typebox/build/format/idna/pattern/pattern.mjs +70 -0
- package/node_modules/typebox/build/format/ipv4.d.mts +0 -1
- package/node_modules/typebox/build/format/ipv4.mjs +2 -32
- package/node_modules/typebox/build/format/ipv6.mjs +2 -61
- package/node_modules/typebox/build/format/iri.d.mts +2 -2
- package/node_modules/typebox/build/format/iri.mjs +26 -8
- package/node_modules/typebox/build/format/iri_reference.d.mts +2 -2
- package/node_modules/typebox/build/format/iri_reference.mjs +9 -55
- package/node_modules/typebox/build/format/regex.d.mts +1 -2
- package/node_modules/typebox/build/format/regex.mjs +2 -6
- package/node_modules/typebox/build/format/time.d.mts +2 -2
- package/node_modules/typebox/build/format/time.mjs +19 -14
- package/node_modules/typebox/build/format/uri.d.mts +1 -1
- package/node_modules/typebox/build/format/uri.mjs +3 -130
- package/node_modules/typebox/build/format/uri_reference.d.mts +1 -1
- package/node_modules/typebox/build/format/uri_reference.mjs +2 -3
- package/node_modules/typebox/build/format/uri_template.d.mts +2 -3
- package/node_modules/typebox/build/format/uri_template.mjs +4 -5
- package/node_modules/typebox/build/format/url.d.mts +3 -3
- package/node_modules/typebox/build/format/url.mjs +4 -5
- package/node_modules/typebox/build/guard/emit.d.mts +3 -1
- package/node_modules/typebox/build/guard/emit.mjs +12 -5
- package/node_modules/typebox/build/guard/guard.d.mts +8 -2
- package/node_modules/typebox/build/guard/guard.mjs +25 -4
- package/node_modules/typebox/build/guard/string.d.mts +2 -2
- package/node_modules/typebox/build/guard/string.mjs +7 -7
- package/node_modules/typebox/build/schema/engine/_context.mjs +3 -3
- package/node_modules/typebox/build/schema/engine/_functions.mjs +1 -2
- package/node_modules/typebox/build/schema/engine/_regexp.d.mts +2 -0
- package/node_modules/typebox/build/schema/engine/_regexp.mjs +4 -0
- package/node_modules/typebox/build/schema/engine/_stack.mjs +12 -13
- package/node_modules/typebox/build/schema/engine/additionalItems.mjs +17 -7
- package/node_modules/typebox/build/schema/engine/additionalProperties.mjs +4 -3
- package/node_modules/typebox/build/schema/engine/contains.mjs +18 -6
- package/node_modules/typebox/build/schema/engine/enum.mjs +1 -1
- package/node_modules/typebox/build/schema/engine/items.mjs +26 -6
- package/node_modules/typebox/build/schema/engine/maxContains.mjs +3 -3
- package/node_modules/typebox/build/schema/engine/minContains.mjs +14 -4
- package/node_modules/typebox/build/schema/engine/not.mjs +4 -2
- package/node_modules/typebox/build/schema/engine/oneOf.mjs +7 -6
- package/node_modules/typebox/build/schema/engine/pattern.mjs +3 -2
- package/node_modules/typebox/build/schema/engine/patternProperties.mjs +4 -3
- package/node_modules/typebox/build/schema/engine/ref.mjs +1 -7
- package/node_modules/typebox/build/schema/engine/schema.mjs +13 -4
- package/node_modules/typebox/build/schema/engine/type.mjs +1 -1
- package/node_modules/typebox/build/schema/resolve/resolve.d.mts +4 -1
- package/node_modules/typebox/build/schema/resolve/resolve.mjs +202 -1
- package/node_modules/typebox/build/schema/static/propertyNames.d.mts +5 -0
- package/node_modules/typebox/build/schema/static/propertyNames.mjs +3 -0
- package/node_modules/typebox/build/schema/static/schema.d.mts +3 -0
- package/node_modules/typebox/build/schema/types/index.d.mts +0 -2
- package/node_modules/typebox/build/schema/types/index.mjs +0 -2
- package/node_modules/typebox/build/system/memory/clone.mjs +14 -11
- package/node_modules/typebox/build/system/memory/discard.mjs +6 -5
- package/node_modules/typebox/build/system/settings/settings.d.mts +9 -0
- package/node_modules/typebox/build/system/settings/settings.mjs +2 -0
- package/node_modules/typebox/build/type/engine/call/distribute_arguments.d.mts +6 -1
- package/node_modules/typebox/build/type/engine/call/distribute_arguments.mjs +16 -3
- package/node_modules/typebox/build/type/engine/call/instantiate.mjs +34 -4
- package/node_modules/typebox/build/type/engine/evaluate/broaden.d.mts +5 -5
- package/node_modules/typebox/build/type/engine/evaluate/broaden.mjs +20 -26
- package/node_modules/typebox/build/type/engine/evaluate/compare.d.mts +6 -10
- package/node_modules/typebox/build/type/engine/evaluate/compare.mjs +9 -13
- package/node_modules/typebox/build/type/engine/evaluate/composite.d.mts +7 -4
- package/node_modules/typebox/build/type/engine/evaluate/composite.mjs +12 -19
- package/node_modules/typebox/build/type/engine/evaluate/distribute.d.mts +4 -20
- package/node_modules/typebox/build/type/engine/evaluate/distribute.mjs +8 -20
- package/node_modules/typebox/build/type/engine/evaluate/evaluate.d.mts +4 -4
- package/node_modules/typebox/build/type/engine/evaluate/evaluate.mjs +11 -8
- package/node_modules/typebox/build/type/engine/evaluate/flatten.d.mts +1 -1
- package/node_modules/typebox/build/type/engine/evaluate/flatten.mjs +3 -4
- package/node_modules/typebox/build/type/engine/evaluate/narrow.d.mts +17 -2
- package/node_modules/typebox/build/type/engine/evaluate/narrow.mjs +26 -6
- package/node_modules/typebox/build/type/engine/exclude/operation.mjs +3 -4
- package/node_modules/typebox/build/type/engine/extract/operation.d.mts +1 -1
- package/node_modules/typebox/build/type/engine/extract/operation.mjs +3 -4
- package/node_modules/typebox/build/type/engine/priority/priority.d.mts +2 -2
- package/node_modules/typebox/build/type/engine/priority/priority.mjs +3 -4
- package/node_modules/typebox/build/type/script/mapping.d.mts +32 -29
- package/node_modules/typebox/build/type/script/mapping.mjs +18 -25
- package/node_modules/typebox/build/type/script/parser.d.mts +19 -25
- package/node_modules/typebox/build/type/script/parser.mjs +27 -23
- package/node_modules/typebox/build/value/errors/errors.d.mts +2 -2
- package/node_modules/typebox/build/value/errors/errors.mjs +1 -1
- package/node_modules/typebox/package.json +27 -27
- package/node_modules/typebox/readme.md +79 -82
- package/node_modules/undici/docs/docs/api/Client.md +21 -8
- package/node_modules/undici/lib/api/readable.js +33 -43
- package/node_modules/undici/lib/core/connect.js +16 -2
- package/node_modules/undici/lib/core/symbols.js +1 -0
- package/node_modules/undici/lib/dispatcher/client-h1.js +3 -3
- package/node_modules/undici/lib/dispatcher/client-h2.js +179 -10
- package/node_modules/undici/lib/dispatcher/client.js +74 -29
- package/node_modules/undici/lib/dispatcher/env-http-proxy-agent.js +28 -6
- package/node_modules/undici/lib/dispatcher/socks5-proxy-agent.js +15 -1
- package/node_modules/undici/lib/handler/retry-handler.js +7 -2
- package/node_modules/undici/lib/interceptor/cache.js +5 -2
- package/node_modules/undici/lib/interceptor/deduplicate.js +1 -1
- package/node_modules/undici/lib/mock/mock-utils.js +213 -24
- package/node_modules/undici/lib/util/cache.js +2 -4
- package/node_modules/undici/lib/web/websocket/websocket.js +22 -0
- package/node_modules/undici/package.json +1 -1
- package/node_modules/undici/types/client.d.ts +40 -0
- package/node_modules/ws/lib/permessage-deflate.js +3 -1
- package/node_modules/ws/package.json +1 -1
- package/openclaw.plugin.json +24 -10
- package/package.json +8 -10
- package/skills/discord/SKILL.md +1 -1
- package/dist/approval-message-safety-AcIxvrf3.js +0 -140
- package/dist/audit-core-xwjIczO0.js +0 -105
- package/dist/channel-actions-5s_hjYKd.js +0 -208
- package/dist/channel-api-CAJ0wMoV.js +0 -21
- package/dist/inbound-event-delivery-De2qxTrP.js +0 -39
- package/dist/provider.runtime-C9PnJZbZ.js +0 -2
- package/dist/runtime-api.actions.js +0 -3
- package/dist/runtime-api.lookup.js +0 -7
- package/dist/runtime-api.monitor-CHxrFPnW.js +0 -5
- package/dist/runtime-api.monitor.js +0 -8
- package/dist/runtime-api.send.js +0 -7
- package/dist/runtime-api.threads.js +0 -5
- package/dist/send.reactions-BAn0iiVQ.js +0 -78
- package/dist/send.receipt-IPI1p-SP.js +0 -66
- package/dist/subagent-hooks-CTt5KCJr.js +0 -120
- package/dist/subagent-progress-DhaE_h8a.js +0 -109
- package/dist/targets-yUFTHoAx.js +0 -3
- package/dist/transcripts-source-CfFMexGt.js +0 -123
- 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/typebox/build/format/_idna.d.mts +0 -2
- package/node_modules/typebox/build/format/_idna.mjs +0 -246
- package/node_modules/typebox/build/format/_puny.d.mts +0 -1
- package/node_modules/typebox/build/format/_puny.mjs +0 -77
- package/node_modules/typebox/build/schema/resolve/ref.d.mts +0 -3
- package/node_modules/typebox/build/schema/resolve/ref.mjs +0 -146
- package/node_modules/typebox/build/schema/types/contentEncoding.d.mts +0 -9
- package/node_modules/typebox/build/schema/types/contentEncoding.mjs +0 -13
- package/node_modules/typebox/build/schema/types/contentMediaType.d.mts +0 -9
- package/node_modules/typebox/build/schema/types/contentMediaType.mjs +0 -13
- package/dist/{allow-list-DnxIlPP2.js → allow-list-BDMimASD.js} +1 -1
- package/dist/{doctor-contract-DLa-BTiU.js → doctor-contract-DsWvKIXF.js} +1 -1
|
@@ -1,66 +0,0 @@
|
|
|
1
|
-
import { createMessageReceiptFromOutboundResults } from "openclaw/plugin-sdk/channel-outbound";
|
|
2
|
-
import { attachChannelToResults } from "openclaw/plugin-sdk/channel-send-result";
|
|
3
|
-
//#region extensions/discord/src/send.receipt.ts
|
|
4
|
-
function createDiscordSendReceiptFromResults(params) {
|
|
5
|
-
const receipt = createMessageReceiptFromOutboundResults({
|
|
6
|
-
results: attachChannelToResults("discord", params.results),
|
|
7
|
-
threadId: params.threadId
|
|
8
|
-
});
|
|
9
|
-
return {
|
|
10
|
-
...receipt,
|
|
11
|
-
parts: receipt.parts.map(({ platformMessageId, kind, threadId, replyToId, raw }, index) => ({
|
|
12
|
-
platformMessageId,
|
|
13
|
-
kind,
|
|
14
|
-
index,
|
|
15
|
-
threadId,
|
|
16
|
-
replyToId,
|
|
17
|
-
raw
|
|
18
|
-
}))
|
|
19
|
-
};
|
|
20
|
-
}
|
|
21
|
-
function createDiscordSendReceipt(params) {
|
|
22
|
-
return createMessageReceiptFromOutboundResults({
|
|
23
|
-
results: params.platformMessageIds.map((messageId) => messageId.trim()).filter((messageId) => messageId && messageId !== "unknown").map((messageId, index) => {
|
|
24
|
-
const result = {
|
|
25
|
-
channel: "discord",
|
|
26
|
-
messageId
|
|
27
|
-
};
|
|
28
|
-
if (params.channelId) result.channelId = params.channelId;
|
|
29
|
-
if (params.reply?.scope === "first" && index === 0) {
|
|
30
|
-
const rawResult = {
|
|
31
|
-
channel: "discord",
|
|
32
|
-
messageId
|
|
33
|
-
};
|
|
34
|
-
if (params.channelId) rawResult.channelId = params.channelId;
|
|
35
|
-
result.receipt = createMessageReceiptFromOutboundResults({
|
|
36
|
-
results: [rawResult],
|
|
37
|
-
kind: params.kind,
|
|
38
|
-
threadId: params.threadId,
|
|
39
|
-
replyToId: params.reply.messageId
|
|
40
|
-
});
|
|
41
|
-
}
|
|
42
|
-
return result;
|
|
43
|
-
}),
|
|
44
|
-
kind: params.kind,
|
|
45
|
-
threadId: params.threadId,
|
|
46
|
-
replyToId: params.reply?.scope === "all" ? params.reply.messageId : void 0
|
|
47
|
-
});
|
|
48
|
-
}
|
|
49
|
-
function createDiscordSendResult(params) {
|
|
50
|
-
const messageId = params.result.id || "unknown";
|
|
51
|
-
const channelId = params.result.channel_id ?? params.fallbackChannelId;
|
|
52
|
-
const receiptParams = {
|
|
53
|
-
platformMessageIds: params.result.platformMessageIds?.length ? params.result.platformMessageIds : [messageId],
|
|
54
|
-
channelId,
|
|
55
|
-
kind: params.kind
|
|
56
|
-
};
|
|
57
|
-
if (params.threadId != null) receiptParams.threadId = String(params.threadId);
|
|
58
|
-
if (params.reply) receiptParams.reply = params.reply;
|
|
59
|
-
return {
|
|
60
|
-
messageId,
|
|
61
|
-
channelId,
|
|
62
|
-
receipt: createDiscordSendReceipt(receiptParams)
|
|
63
|
-
};
|
|
64
|
-
}
|
|
65
|
-
//#endregion
|
|
66
|
-
export { createDiscordSendReceiptFromResults as n, createDiscordSendResult as r, createDiscordSendReceipt as t };
|
|
@@ -1,120 +0,0 @@
|
|
|
1
|
-
import { tn as __exportAll } from "./retry-CLpJcXXf.js";
|
|
2
|
-
import { s as resolveDiscordAccount } from "./accounts-DJTf1LtA.js";
|
|
3
|
-
import { n as autoBindSpawnedDiscordSubagent, o as unbindThreadBindingsBySessionKey, r as listThreadBindingsBySessionKey } from "./thread-bindings-3L8p82GV.js";
|
|
4
|
-
import { normalizeOptionalLowercaseString, normalizeOptionalStringifiedId } from "openclaw/plugin-sdk/string-coerce-runtime";
|
|
5
|
-
import { formatThreadBindingDisabledError, formatThreadBindingSpawnDisabledError, resolveThreadBindingSpawnPolicy } from "openclaw/plugin-sdk/conversation-runtime";
|
|
6
|
-
//#region extensions/discord/src/subagent-hooks.ts
|
|
7
|
-
var subagent_hooks_exports = /* @__PURE__ */ __exportAll({
|
|
8
|
-
handleDiscordSubagentDeliveryTarget: () => handleDiscordSubagentDeliveryTarget,
|
|
9
|
-
handleDiscordSubagentEnded: () => handleDiscordSubagentEnded,
|
|
10
|
-
handleDiscordSubagentSpawning: () => handleDiscordSubagentSpawning
|
|
11
|
-
});
|
|
12
|
-
function summarizeError(err) {
|
|
13
|
-
if (err instanceof Error) return err.message;
|
|
14
|
-
if (typeof err === "string") return err;
|
|
15
|
-
return "error";
|
|
16
|
-
}
|
|
17
|
-
function normalizeThreadBindingTargetKind(raw) {
|
|
18
|
-
const normalized = normalizeOptionalLowercaseString(raw);
|
|
19
|
-
if (normalized === "subagent" || normalized === "acp") return normalized;
|
|
20
|
-
}
|
|
21
|
-
async function handleDiscordSubagentSpawning(api, event) {
|
|
22
|
-
if (!event.threadRequested) return;
|
|
23
|
-
if (normalizeOptionalLowercaseString(event.requester?.channel) !== "discord") return;
|
|
24
|
-
const account = resolveDiscordAccount({
|
|
25
|
-
cfg: api.config,
|
|
26
|
-
accountId: event.requester?.accountId
|
|
27
|
-
});
|
|
28
|
-
const threadBindingPolicy = resolveThreadBindingSpawnPolicy({
|
|
29
|
-
cfg: api.config,
|
|
30
|
-
channel: "discord",
|
|
31
|
-
accountId: account.accountId,
|
|
32
|
-
kind: "subagent"
|
|
33
|
-
});
|
|
34
|
-
if (!threadBindingPolicy.enabled) return {
|
|
35
|
-
status: "error",
|
|
36
|
-
error: formatThreadBindingDisabledError({
|
|
37
|
-
channel: threadBindingPolicy.channel,
|
|
38
|
-
accountId: threadBindingPolicy.accountId,
|
|
39
|
-
kind: "subagent"
|
|
40
|
-
})
|
|
41
|
-
};
|
|
42
|
-
if (!threadBindingPolicy.spawnEnabled) return {
|
|
43
|
-
status: "error",
|
|
44
|
-
error: formatThreadBindingSpawnDisabledError({
|
|
45
|
-
channel: threadBindingPolicy.channel,
|
|
46
|
-
accountId: threadBindingPolicy.accountId,
|
|
47
|
-
kind: "subagent"
|
|
48
|
-
})
|
|
49
|
-
};
|
|
50
|
-
try {
|
|
51
|
-
const agentId = event.agentId?.trim() || "subagent";
|
|
52
|
-
const binding = await autoBindSpawnedDiscordSubagent({
|
|
53
|
-
cfg: api.config,
|
|
54
|
-
accountId: account.accountId,
|
|
55
|
-
channel: event.requester?.channel,
|
|
56
|
-
to: event.requester?.to,
|
|
57
|
-
threadId: event.requester?.threadId,
|
|
58
|
-
childSessionKey: event.childSessionKey,
|
|
59
|
-
agentId,
|
|
60
|
-
label: event.label,
|
|
61
|
-
boundBy: "system"
|
|
62
|
-
});
|
|
63
|
-
if (!binding) return {
|
|
64
|
-
status: "error",
|
|
65
|
-
error: "Unable to create or bind a Discord thread for this subagent session. Session mode is unavailable for this target."
|
|
66
|
-
};
|
|
67
|
-
return {
|
|
68
|
-
status: "ok",
|
|
69
|
-
threadBindingReady: true,
|
|
70
|
-
deliveryOrigin: {
|
|
71
|
-
channel: "discord",
|
|
72
|
-
accountId: account.accountId,
|
|
73
|
-
to: `channel:${binding.threadId}`,
|
|
74
|
-
threadId: binding.threadId
|
|
75
|
-
}
|
|
76
|
-
};
|
|
77
|
-
} catch (err) {
|
|
78
|
-
return {
|
|
79
|
-
status: "error",
|
|
80
|
-
error: `Discord thread bind failed: ${summarizeError(err)}`
|
|
81
|
-
};
|
|
82
|
-
}
|
|
83
|
-
}
|
|
84
|
-
function handleDiscordSubagentEnded(event) {
|
|
85
|
-
unbindThreadBindingsBySessionKey({
|
|
86
|
-
targetSessionKey: event.targetSessionKey,
|
|
87
|
-
accountId: event.accountId,
|
|
88
|
-
targetKind: normalizeThreadBindingTargetKind(event.targetKind),
|
|
89
|
-
reason: event.reason,
|
|
90
|
-
sendFarewell: event.sendFarewell
|
|
91
|
-
});
|
|
92
|
-
}
|
|
93
|
-
function handleDiscordSubagentDeliveryTarget(event) {
|
|
94
|
-
if (!event.expectsCompletionMessage) return;
|
|
95
|
-
if (normalizeOptionalLowercaseString(event.requesterOrigin?.channel) !== "discord") return;
|
|
96
|
-
const requesterAccountId = event.requesterOrigin?.accountId?.trim();
|
|
97
|
-
const requesterThreadId = event.requesterOrigin?.threadId != null && event.requesterOrigin.threadId !== "" ? normalizeOptionalStringifiedId(event.requesterOrigin.threadId) ?? "" : "";
|
|
98
|
-
const bindings = listThreadBindingsBySessionKey({
|
|
99
|
-
targetSessionKey: event.childSessionKey,
|
|
100
|
-
...requesterAccountId ? { accountId: requesterAccountId } : {},
|
|
101
|
-
targetKind: "subagent"
|
|
102
|
-
});
|
|
103
|
-
if (bindings.length === 0) return;
|
|
104
|
-
let binding;
|
|
105
|
-
if (requesterThreadId) binding = bindings.find((entry) => {
|
|
106
|
-
if (entry.threadId !== requesterThreadId) return false;
|
|
107
|
-
if (requesterAccountId && entry.accountId !== requesterAccountId) return false;
|
|
108
|
-
return true;
|
|
109
|
-
});
|
|
110
|
-
if (!binding && bindings.length === 1) binding = bindings[0];
|
|
111
|
-
if (!binding) return;
|
|
112
|
-
return { origin: {
|
|
113
|
-
channel: "discord",
|
|
114
|
-
accountId: binding.accountId,
|
|
115
|
-
to: `channel:${binding.threadId}`,
|
|
116
|
-
threadId: binding.threadId
|
|
117
|
-
} };
|
|
118
|
-
}
|
|
119
|
-
//#endregion
|
|
120
|
-
export { subagent_hooks_exports as i, handleDiscordSubagentEnded as n, handleDiscordSubagentSpawning as r, handleDiscordSubagentDeliveryTarget as t };
|
|
@@ -1,109 +0,0 @@
|
|
|
1
|
-
import { l as resolveDiscordAccountConfig, s as resolveDiscordAccount } from "./accounts-DJTf1LtA.js";
|
|
2
|
-
import { i as removeReactionDiscord } from "./send.reactions-BAn0iiVQ.js";
|
|
3
|
-
import { DEFAULT_ACCOUNT_ID } from "openclaw/plugin-sdk/routing";
|
|
4
|
-
import { DEFAULT_EMOJIS } from "openclaw/plugin-sdk/channel-feedback";
|
|
5
|
-
//#region extensions/discord/src/subagent-progress.ts
|
|
6
|
-
const PROGRESS_STORE_TTL_MS = 10080 * 6e4;
|
|
7
|
-
const MAX_TRACKED_RUNS = 4096;
|
|
8
|
-
const RETRY_BASE_DELAY_MS = 1e3;
|
|
9
|
-
const RETRY_MAX_DELAY_MS = 60 * 6e4;
|
|
10
|
-
const RETRY_MAX_ATTEMPTS = 12;
|
|
11
|
-
const HISTORICAL_RUNNING_EMOJIS = /* @__PURE__ */ new Set([
|
|
12
|
-
"1️⃣",
|
|
13
|
-
"2️⃣",
|
|
14
|
-
"3️⃣",
|
|
15
|
-
"4️⃣",
|
|
16
|
-
"5️⃣",
|
|
17
|
-
"6️⃣",
|
|
18
|
-
"7️⃣",
|
|
19
|
-
"8️⃣",
|
|
20
|
-
"9️⃣",
|
|
21
|
-
"🔟"
|
|
22
|
-
]);
|
|
23
|
-
const recoveryRetries = /* @__PURE__ */ new Map();
|
|
24
|
-
function logFailure(api, action, error) {
|
|
25
|
-
const message = error instanceof Error ? error.message : String(error);
|
|
26
|
-
api.logger.debug?.(`discord retired subagent progress ${action} failed: ${message}`);
|
|
27
|
-
}
|
|
28
|
-
function reservedReactionEmojis(api, accountAckReaction) {
|
|
29
|
-
const reserved = new Set(Object.values(DEFAULT_EMOJIS));
|
|
30
|
-
for (const emoji of [api.config.messages?.ackReaction, accountAckReaction]) if (emoji?.trim()) reserved.add(emoji.trim());
|
|
31
|
-
for (const agent of api.config.agents?.list ?? []) {
|
|
32
|
-
const emoji = agent.identity?.emoji?.trim();
|
|
33
|
-
if (emoji) reserved.add(emoji);
|
|
34
|
-
}
|
|
35
|
-
return reserved;
|
|
36
|
-
}
|
|
37
|
-
function clearRecoveryRetry(api) {
|
|
38
|
-
const retry = recoveryRetries.get(api);
|
|
39
|
-
if (retry?.timer) clearTimeout(retry.timer);
|
|
40
|
-
recoveryRetries.delete(api);
|
|
41
|
-
}
|
|
42
|
-
function scheduleRecoveryRetry(api) {
|
|
43
|
-
const retry = recoveryRetries.get(api) ?? { attempts: 0 };
|
|
44
|
-
if (retry.timer || retry.attempts >= RETRY_MAX_ATTEMPTS) return;
|
|
45
|
-
const delayMs = Math.min(RETRY_BASE_DELAY_MS * 2 ** retry.attempts, RETRY_MAX_DELAY_MS);
|
|
46
|
-
retry.attempts += 1;
|
|
47
|
-
retry.timer = setTimeout(() => {
|
|
48
|
-
retry.timer = void 0;
|
|
49
|
-
recoverDiscordSubagentProgress(api);
|
|
50
|
-
}, delayMs);
|
|
51
|
-
retry.timer.unref?.();
|
|
52
|
-
recoveryRetries.set(api, retry);
|
|
53
|
-
}
|
|
54
|
-
async function cleanPersistedReaction(api, store, entry) {
|
|
55
|
-
try {
|
|
56
|
-
if (entry.value.accountId !== DEFAULT_ACCOUNT_ID && !resolveDiscordAccountConfig(api.config, entry.value.accountId)) return false;
|
|
57
|
-
const account = resolveDiscordAccount({
|
|
58
|
-
cfg: api.config,
|
|
59
|
-
accountId: entry.value.accountId
|
|
60
|
-
});
|
|
61
|
-
if (!account.enabled || account.tokenStatus !== "available") return false;
|
|
62
|
-
const emoji = entry.value.runningEmoji;
|
|
63
|
-
if (emoji && HISTORICAL_RUNNING_EMOJIS.has(emoji) && !reservedReactionEmojis(api, account.config.ackReaction).has(emoji)) await removeReactionDiscord(entry.value.channelId, entry.value.messageId, emoji, {
|
|
64
|
-
cfg: api.config,
|
|
65
|
-
accountId: entry.value.accountId
|
|
66
|
-
});
|
|
67
|
-
await store.consume(entry.key);
|
|
68
|
-
return true;
|
|
69
|
-
} catch (error) {
|
|
70
|
-
logFailure(api, "startup cleanup", error);
|
|
71
|
-
return false;
|
|
72
|
-
}
|
|
73
|
-
}
|
|
74
|
-
async function recoverDiscordSubagentProgressImpl(api) {
|
|
75
|
-
let store;
|
|
76
|
-
try {
|
|
77
|
-
store = api.runtime.state.openKeyedStore({
|
|
78
|
-
namespace: "subagent-progress",
|
|
79
|
-
maxEntries: MAX_TRACKED_RUNS,
|
|
80
|
-
overflowPolicy: "reject-new",
|
|
81
|
-
defaultTtlMs: PROGRESS_STORE_TTL_MS
|
|
82
|
-
});
|
|
83
|
-
} catch (error) {
|
|
84
|
-
logFailure(api, "state store open", error);
|
|
85
|
-
scheduleRecoveryRetry(api);
|
|
86
|
-
return;
|
|
87
|
-
}
|
|
88
|
-
let entries;
|
|
89
|
-
try {
|
|
90
|
-
entries = await store.entries();
|
|
91
|
-
} catch (error) {
|
|
92
|
-
logFailure(api, "startup recovery list", error);
|
|
93
|
-
scheduleRecoveryRetry(api);
|
|
94
|
-
return;
|
|
95
|
-
}
|
|
96
|
-
let retryNeeded = false;
|
|
97
|
-
for (const entry of entries) if (!await cleanPersistedReaction(api, store, entry)) retryNeeded = true;
|
|
98
|
-
if (retryNeeded) scheduleRecoveryRetry(api);
|
|
99
|
-
else clearRecoveryRetry(api);
|
|
100
|
-
}
|
|
101
|
-
function resetDiscordSubagentProgressForTest() {
|
|
102
|
-
for (const [api, retry] of recoveryRetries) {
|
|
103
|
-
if (retry.timer) clearTimeout(retry.timer);
|
|
104
|
-
recoveryRetries.delete(api);
|
|
105
|
-
}
|
|
106
|
-
}
|
|
107
|
-
const recoverDiscordSubagentProgress = Object.assign(recoverDiscordSubagentProgressImpl, { resetForTest: resetDiscordSubagentProgressForTest });
|
|
108
|
-
//#endregion
|
|
109
|
-
export { recoverDiscordSubagentProgress };
|
package/dist/targets-yUFTHoAx.js
DELETED
|
@@ -1,123 +0,0 @@
|
|
|
1
|
-
import { tn as __exportAll } from "./retry-CLpJcXXf.js";
|
|
2
|
-
//#region extensions/discord/src/voice/transcripts-source.ts
|
|
3
|
-
var transcripts_source_exports = /* @__PURE__ */ __exportAll({
|
|
4
|
-
discordVoiceTranscriptsSourceProvider: () => discordVoiceTranscriptsSourceProvider,
|
|
5
|
-
setDiscordTranscriptsVoiceManager: () => setDiscordTranscriptsVoiceManager
|
|
6
|
-
});
|
|
7
|
-
const managersByAccountId = /* @__PURE__ */ new Map();
|
|
8
|
-
const managerWaiters = /* @__PURE__ */ new Set();
|
|
9
|
-
function setDiscordTranscriptsVoiceManager(params) {
|
|
10
|
-
if (params.manager) {
|
|
11
|
-
managersByAccountId.set(params.accountId, params.manager);
|
|
12
|
-
for (const waiter of managerWaiters) if (!waiter.accountId || waiter.accountId === params.accountId) waiter.resolve();
|
|
13
|
-
} else managersByAccountId.delete(params.accountId);
|
|
14
|
-
}
|
|
15
|
-
function resolveManager(request) {
|
|
16
|
-
const accountId = request.session.source.accountId?.trim();
|
|
17
|
-
if (accountId) return managersByAccountId.get(accountId);
|
|
18
|
-
return [...managersByAccountId.values()][0];
|
|
19
|
-
}
|
|
20
|
-
async function waitForManager(request) {
|
|
21
|
-
const existing = resolveManager(request);
|
|
22
|
-
if (existing) return existing;
|
|
23
|
-
if (request.abortSignal?.aborted) return;
|
|
24
|
-
const startupWaitMs = request.startupWaitMs ?? 0;
|
|
25
|
-
if (startupWaitMs <= 0) return;
|
|
26
|
-
const accountId = request.session.source.accountId?.trim() || void 0;
|
|
27
|
-
await new Promise((resolve) => {
|
|
28
|
-
const waiter = {
|
|
29
|
-
accountId,
|
|
30
|
-
resolve: () => {
|
|
31
|
-
clearTimeout(timer);
|
|
32
|
-
request.abortSignal?.removeEventListener("abort", waiter.resolve);
|
|
33
|
-
managerWaiters.delete(waiter);
|
|
34
|
-
resolve();
|
|
35
|
-
}
|
|
36
|
-
};
|
|
37
|
-
const timer = setTimeout(waiter.resolve, startupWaitMs);
|
|
38
|
-
timer.unref?.();
|
|
39
|
-
request.abortSignal?.addEventListener("abort", waiter.resolve, { once: true });
|
|
40
|
-
managerWaiters.add(waiter);
|
|
41
|
-
});
|
|
42
|
-
if (request.abortSignal?.aborted) return;
|
|
43
|
-
return resolveManager(request);
|
|
44
|
-
}
|
|
45
|
-
const discordVoiceTranscriptsSourceProvider = {
|
|
46
|
-
id: "discord-voice",
|
|
47
|
-
aliases: ["discord"],
|
|
48
|
-
name: "Discord Voice",
|
|
49
|
-
sourceKinds: ["live-audio"],
|
|
50
|
-
async start(request) {
|
|
51
|
-
const manager = await waitForManager(request);
|
|
52
|
-
if (!manager) return {
|
|
53
|
-
ok: false,
|
|
54
|
-
error: "Discord voice manager is not available."
|
|
55
|
-
};
|
|
56
|
-
if (request.abortSignal?.aborted) return {
|
|
57
|
-
ok: false,
|
|
58
|
-
error: "Discord transcripts start aborted."
|
|
59
|
-
};
|
|
60
|
-
const guildId = request.session.source.guildId?.trim();
|
|
61
|
-
const channelId = request.session.source.channelId?.trim();
|
|
62
|
-
if (!guildId || !channelId) return {
|
|
63
|
-
ok: false,
|
|
64
|
-
error: "Discord transcripts require guildId and channelId."
|
|
65
|
-
};
|
|
66
|
-
const joined = await manager.join({
|
|
67
|
-
guildId,
|
|
68
|
-
channelId
|
|
69
|
-
}, { transcripts: {
|
|
70
|
-
sessionId: request.session.sessionId,
|
|
71
|
-
onUtterance: request.onUtterance
|
|
72
|
-
} });
|
|
73
|
-
if (!joined.ok) return {
|
|
74
|
-
ok: false,
|
|
75
|
-
error: joined.message
|
|
76
|
-
};
|
|
77
|
-
return {
|
|
78
|
-
ok: true,
|
|
79
|
-
session: request.session
|
|
80
|
-
};
|
|
81
|
-
},
|
|
82
|
-
async stop(request) {
|
|
83
|
-
const accountId = request.source.accountId?.trim();
|
|
84
|
-
const manager = accountId ? managersByAccountId.get(accountId) : [...managersByAccountId.values()][0];
|
|
85
|
-
if (!manager) return {
|
|
86
|
-
ok: false,
|
|
87
|
-
error: "Discord voice manager is not available."
|
|
88
|
-
};
|
|
89
|
-
const guildId = request.source.guildId?.trim();
|
|
90
|
-
if (!guildId) return {
|
|
91
|
-
ok: false,
|
|
92
|
-
error: "Discord transcripts require guildId."
|
|
93
|
-
};
|
|
94
|
-
const result = await manager.leave({
|
|
95
|
-
guildId,
|
|
96
|
-
channelId: request.source.channelId
|
|
97
|
-
}, { transcriptsSessionId: request.sessionId });
|
|
98
|
-
if (!result.ok) return {
|
|
99
|
-
ok: false,
|
|
100
|
-
error: result.message
|
|
101
|
-
};
|
|
102
|
-
return {
|
|
103
|
-
ok: true,
|
|
104
|
-
sessionId: request.sessionId,
|
|
105
|
-
stoppedAt: (/* @__PURE__ */ new Date()).toISOString()
|
|
106
|
-
};
|
|
107
|
-
},
|
|
108
|
-
async status(source) {
|
|
109
|
-
const accountId = source.accountId?.trim();
|
|
110
|
-
return (accountId ? managersByAccountId.get(accountId) : [...managersByAccountId.values()][0])?.status().map((entry) => ({
|
|
111
|
-
active: entry.ok,
|
|
112
|
-
message: entry.message,
|
|
113
|
-
source: {
|
|
114
|
-
providerId: "discord-voice",
|
|
115
|
-
accountId,
|
|
116
|
-
guildId: entry.guildId,
|
|
117
|
-
channelId: entry.channelId
|
|
118
|
-
}
|
|
119
|
-
})) ?? [];
|
|
120
|
-
}
|
|
121
|
-
};
|
|
122
|
-
//#endregion
|
|
123
|
-
export { transcripts_source_exports as n, discordVoiceTranscriptsSourceProvider as t };
|
|
@@ -1,155 +0,0 @@
|
|
|
1
|
-
type BaseOptions = {
|
|
2
|
-
/**
|
|
3
|
-
Number of concurrently pending promises returned by `mapper`.
|
|
4
|
-
|
|
5
|
-
Must be an integer from 1 and up or `Infinity`.
|
|
6
|
-
|
|
7
|
-
@default Infinity
|
|
8
|
-
*/
|
|
9
|
-
readonly concurrency?: number;
|
|
10
|
-
};
|
|
11
|
-
|
|
12
|
-
export type Options = BaseOptions & {
|
|
13
|
-
/**
|
|
14
|
-
When `true`, the first mapper rejection will be rejected back to the consumer.
|
|
15
|
-
|
|
16
|
-
When `false`, instead of stopping when a promise rejects, it will wait for all the promises to settle and then reject with an [`AggregateError`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/AggregateError) containing all the errors from the rejected promises.
|
|
17
|
-
|
|
18
|
-
Caveat: When `true`, any already-started async mappers will continue to run until they resolve or reject. In the case of infinite concurrency with sync iterables, *all* mappers are invoked on startup and will continue after the first rejection. Use the `signal` option for abort control.
|
|
19
|
-
|
|
20
|
-
@default true
|
|
21
|
-
*/
|
|
22
|
-
readonly stopOnError?: boolean;
|
|
23
|
-
|
|
24
|
-
/**
|
|
25
|
-
You can abort the promises using [`AbortController`](https://developer.mozilla.org/en-US/docs/Web/API/AbortController).
|
|
26
|
-
|
|
27
|
-
@example
|
|
28
|
-
```
|
|
29
|
-
import pMap from 'p-map';
|
|
30
|
-
import delay from 'delay';
|
|
31
|
-
|
|
32
|
-
const abortController = new AbortController();
|
|
33
|
-
|
|
34
|
-
setTimeout(() => {
|
|
35
|
-
abortController.abort();
|
|
36
|
-
}, 500);
|
|
37
|
-
|
|
38
|
-
const mapper = async value => value;
|
|
39
|
-
|
|
40
|
-
await pMap([delay(1000), delay(1000)], mapper, {signal: abortController.signal});
|
|
41
|
-
// Throws AbortError (DOMException) after 500 ms.
|
|
42
|
-
```
|
|
43
|
-
*/
|
|
44
|
-
readonly signal?: AbortSignal | undefined;
|
|
45
|
-
};
|
|
46
|
-
|
|
47
|
-
export type IterableOptions = BaseOptions & {
|
|
48
|
-
/**
|
|
49
|
-
Maximum number of promises returned by `mapper` that have resolved but not yet collected by the consumer of the async iterable. Calls to `mapper` will be limited so that there is never too much backpressure.
|
|
50
|
-
|
|
51
|
-
Useful whenever you are consuming the iterable slower than what the mapper function can produce concurrently. For example, to avoid making an overwhelming number of HTTP requests if you are saving each of the results to a database.
|
|
52
|
-
|
|
53
|
-
Default: `options.concurrency`
|
|
54
|
-
*/
|
|
55
|
-
readonly backpressure?: number;
|
|
56
|
-
};
|
|
57
|
-
|
|
58
|
-
type MaybePromise<T> = T | Promise<T>;
|
|
59
|
-
|
|
60
|
-
/**
|
|
61
|
-
Function which is called for every item in `input`. Expected to return a `Promise` or value.
|
|
62
|
-
|
|
63
|
-
@param element - Iterated element.
|
|
64
|
-
@param index - Index of the element in the source array.
|
|
65
|
-
*/
|
|
66
|
-
export type Mapper<Element = any, NewElement = unknown> = (
|
|
67
|
-
element: Element,
|
|
68
|
-
index: number
|
|
69
|
-
) => MaybePromise<NewElement | typeof pMapSkip>;
|
|
70
|
-
|
|
71
|
-
/**
|
|
72
|
-
@param input - Synchronous or asynchronous iterable that is iterated over concurrently, calling the `mapper` function for each element. Each iterated item is `await`'d before the `mapper` is invoked so the iterable may return a `Promise` that resolves to an item. Asynchronous iterables (different from synchronous iterables that return `Promise` that resolves to an item) can be used when the next item may not be ready without waiting for an asynchronous process to complete and/or the end of the iterable may be reached after the asynchronous process completes. For example, reading from a remote queue when the queue has reached empty, or reading lines from a stream.
|
|
73
|
-
@param mapper - Function which is called for every item in `input`. Expected to return a `Promise` or value.
|
|
74
|
-
@returns A `Promise` that is fulfilled when all promises in `input` and the ones returned from `mapper` are fulfilled, or rejects if any of the promises reject. The fulfilled value is an `Array` of the fulfilled values returned from `mapper` in `input` order.
|
|
75
|
-
|
|
76
|
-
@example
|
|
77
|
-
```
|
|
78
|
-
import pMap from 'p-map';
|
|
79
|
-
import got from 'got';
|
|
80
|
-
|
|
81
|
-
const sites = [
|
|
82
|
-
getWebsiteFromUsername('sindresorhus'), //=> Promise
|
|
83
|
-
'https://avajs.dev',
|
|
84
|
-
'https://github.com'
|
|
85
|
-
];
|
|
86
|
-
|
|
87
|
-
const mapper = async site => {
|
|
88
|
-
const {requestUrl} = await got.head(site);
|
|
89
|
-
return requestUrl;
|
|
90
|
-
};
|
|
91
|
-
|
|
92
|
-
const result = await pMap(sites, mapper, {concurrency: 2});
|
|
93
|
-
|
|
94
|
-
console.log(result);
|
|
95
|
-
//=> ['https://sindresorhus.com/', 'https://avajs.dev/', 'https://github.com/']
|
|
96
|
-
```
|
|
97
|
-
*/
|
|
98
|
-
export default function pMap<Element, NewElement>(
|
|
99
|
-
input: AsyncIterable<Element | Promise<Element>> | Iterable<Element | Promise<Element>>,
|
|
100
|
-
mapper: Mapper<Element, NewElement>,
|
|
101
|
-
options?: Options
|
|
102
|
-
): Promise<Array<Exclude<NewElement, typeof pMapSkip>>>;
|
|
103
|
-
|
|
104
|
-
/**
|
|
105
|
-
@param input - Synchronous or asynchronous iterable that is iterated over concurrently, calling the `mapper` function for each element. Each iterated item is `await`'d before the `mapper` is invoked so the iterable may return a `Promise` that resolves to an item. Asynchronous iterables (different from synchronous iterables that return `Promise` that resolves to an item) can be used when the next item may not be ready without waiting for an asynchronous process to complete and/or the end of the iterable may be reached after the asynchronous process completes. For example, reading from a remote queue when the queue has reached empty, or reading lines from a stream.
|
|
106
|
-
@param mapper - Function which is called for every item in `input`. Expected to return a `Promise` or value.
|
|
107
|
-
@returns An async iterable that streams each return value from `mapper` in order.
|
|
108
|
-
|
|
109
|
-
@example
|
|
110
|
-
```
|
|
111
|
-
import {pMapIterable} from 'p-map';
|
|
112
|
-
|
|
113
|
-
// Multiple posts are fetched concurrently, with limited concurrency and backpressure
|
|
114
|
-
for await (const post of pMapIterable(postIds, getPostMetadata, {concurrency: 8})) {
|
|
115
|
-
console.log(post);
|
|
116
|
-
};
|
|
117
|
-
```
|
|
118
|
-
*/
|
|
119
|
-
export function pMapIterable<Element, NewElement>(
|
|
120
|
-
input: AsyncIterable<Element | Promise<Element>> | Iterable<Element | Promise<Element>>,
|
|
121
|
-
mapper: Mapper<Element, NewElement>,
|
|
122
|
-
options?: IterableOptions
|
|
123
|
-
): AsyncIterable<Exclude<NewElement, typeof pMapSkip>>;
|
|
124
|
-
|
|
125
|
-
/**
|
|
126
|
-
Return this value from a `mapper` function to skip including the value in the returned array.
|
|
127
|
-
|
|
128
|
-
@example
|
|
129
|
-
```
|
|
130
|
-
import pMap, {pMapSkip} from 'p-map';
|
|
131
|
-
import got from 'got';
|
|
132
|
-
|
|
133
|
-
const sites = [
|
|
134
|
-
getWebsiteFromUsername('sindresorhus'), //=> Promise
|
|
135
|
-
'https://avajs.dev',
|
|
136
|
-
'https://example.invalid',
|
|
137
|
-
'https://github.com'
|
|
138
|
-
];
|
|
139
|
-
|
|
140
|
-
const mapper = async site => {
|
|
141
|
-
try {
|
|
142
|
-
const {requestUrl} = await got.head(site);
|
|
143
|
-
return requestUrl;
|
|
144
|
-
} catch {
|
|
145
|
-
return pMapSkip;
|
|
146
|
-
}
|
|
147
|
-
};
|
|
148
|
-
|
|
149
|
-
const result = await pMap(sites, mapper, {concurrency: 2});
|
|
150
|
-
|
|
151
|
-
console.log(result);
|
|
152
|
-
//=> ['https://sindresorhus.com/', 'https://avajs.dev/', 'https://github.com/']
|
|
153
|
-
```
|
|
154
|
-
*/
|
|
155
|
-
export const pMapSkip: unique symbol;
|