@openclaw/discord 2026.9.4 → 2026.9.5
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/assets/activity.svg +40 -0
- package/assets/icon.png +0 -0
- package/dist/{account-inspect-BY-ve3yH.js → .setup/account-inspect-BwQj24ht.mjs} +1 -1
- package/dist/{activities-api-w8j7Elou.js → .setup/activities-api-DBwRt5ES.mjs} +93 -31
- package/dist/{api-LIV--eMq.js → .setup/api-CBK9zcq5.mjs} +7 -4
- package/dist/{approval-handler.runtime-BnPUU5NK.js → .setup/approval-handler.runtime-Du3n5ypX.mjs} +8 -7
- package/dist/.setup/approval-message-updates-BN7JtScm.mjs +17 -0
- package/dist/{audit-BgAgIzwo.js → .setup/audit-C8uaKoa9.mjs} +5 -5
- package/dist/{channel-C_OFFR5Y.js → .setup/channel-ChKdlBgH.mjs} +27 -25
- package/dist/{channel-actions.runtime-tShzmemq.js → .setup/channel-actions.runtime-CJmiFfps.mjs} +18 -11
- package/dist/{allow-list-DWEio925.js → .setup/channel-type-DKnjV1XW.mjs} +161 -1
- package/dist/{channel.setup-CpAwAiS0.js → .setup/channel.setup-BlC3-Kzz.mjs} +4 -4
- package/dist/{components-DBFTIN6P.js → .setup/components-MqMWUWnE.mjs} +3 -3
- package/dist/{config-schema-r38UkM_J.js → .setup/config-schema-CiZz-mtA.mjs} +1 -1
- package/dist/{conversation-binding-route-CB9PRqgi.js → .setup/conversation-binding-route-_rz33QHO.mjs} +1 -1
- package/dist/{directory-config-D1uDGbWh.js → .setup/directory-config-BytTftz-.mjs} +2 -2
- package/dist/{directory-live-C5o1uKlw.js → .setup/directory-live--EGTH0DC.mjs} +4 -4
- package/dist/{discord-CmL3ati-.js → .setup/discord-BXpHW-cu.mjs} +89 -39
- package/dist/{doctor-DgKMH6N7.js → .setup/doctor-DxcdkXzz.mjs} +6 -6
- package/dist/{handle-action.guild-admin-CpEwox_X.js → .setup/handle-action.guild-admin-DAFyh_yV.mjs} +9 -4
- package/dist/{live-policy-config-BblutQAq.js → .setup/live-policy-config-eKQ-PLdy.mjs} +1 -1
- package/dist/{message-handler-C7FZGKa8.js → .setup/message-handler-DnUrDpaU.mjs} +23 -13
- package/dist/{message-handler.preflight-DFpwDW2W.js → .setup/message-handler.preflight-CtqaF_fb.mjs} +33 -20
- package/dist/{message-handler.process-ZKrmmA9D.js → .setup/message-handler.process-Dz1xvuQU.mjs} +68 -78
- package/dist/{outbound-adapter-C8PTt7_p.js → .setup/outbound-adapter-C8v79z9Z.mjs} +13 -9
- package/dist/{outbound-session-route-B0N6os97.js → .setup/outbound-session-route-CqWbuMOm.mjs} +137 -11
- package/dist/{pluralkit-BiUW53Yn.js → .setup/pluralkit-CdAt1G0P.mjs} +2 -2
- package/dist/{probe-BcoN44eK.js → .setup/probe-CupW4we4.mjs} +14 -10
- package/dist/{probe.runtime-BnuED0fI.js → .setup/probe.runtime-DBQ_AGPe.mjs} +1 -1
- package/dist/{provider-DmRHCZ_K.js → .setup/provider-72zIvN-i.mjs} +475 -286
- package/dist/{provider-session.runtime-U1M8_EYY.js → .setup/provider-session.runtime-BW7QrF5C.mjs} +4 -4
- package/dist/.setup/provider.runtime-DuhmKdDU.mjs +2 -0
- package/dist/{realtime-session.runtime-Bjsk9Q5t.js → .setup/realtime-session.runtime-DTccTgTM.mjs} +758 -336
- package/dist/{resolve-allowlist-common-ChPf0Qy7.js → .setup/resolve-allowlist-common-CwMBzbx9.mjs} +3 -3
- package/dist/{resolve-channels-VbpLmUS8.js → .setup/resolve-channels-BbvsLQOZ.mjs} +4 -5
- package/dist/{resolve-users-D-wRFsd5.js → .setup/resolve-users-ByFlR7LQ.mjs} +3 -3
- package/dist/{retry-DKeoT7UO.js → .setup/retry-DBfcEgmO.mjs} +28 -6
- package/dist/{runtime-CbknwoBH.js → .setup/runtime-BVoa7hhx.mjs} +2 -2
- package/dist/{runtime-Dxl-ZOvg.js → .setup/runtime-SchNfUsQ.mjs} +92 -139
- package/dist/{security-audit-DKfK-iPY.js → .setup/security-audit-s5w50-Ly.mjs} +1 -1
- package/dist/{security-audit.runtime-sKZyKgpx.js → .setup/security-audit.runtime-DHtYenx9.mjs} +1 -1
- package/dist/{send-CLpzfzJe.js → .setup/send-CKDczUNL.mjs} +60 -31
- package/dist/{send.components-BWnkX4QN.js → .setup/send.components-DWQjXhPV.mjs} +87 -65
- package/dist/{send.outbound-BVTWrl_4.js → .setup/send.outbound-D0hQ7s50.mjs} +17 -7
- package/dist/{send.shared-BHPM3CSl.js → .setup/send.shared-Zwx6BxQ5.mjs} +15 -12
- package/dist/{sender-identity-f3l5OYgV.js → .setup/sender-identity-0Ymgvmaj.mjs} +1 -1
- package/dist/.setup/setup-plugin-api-CINIEBLa.mjs +3 -0
- package/dist/{shared-CPPR0Xo4.js → .setup/shared-CaA3Vv4n.mjs} +11 -11
- package/dist/{subagent-hooks-DfsiwCec.js → .setup/subagent-hooks-Bired9q6.mjs} +16 -4
- package/dist/{system-events-B6HkUhF_.js → .setup/system-events-B2YEEMbS.mjs} +2 -2
- package/dist/{target-resolver-CoFQ7iSX.js → .setup/target-resolver-B6MrxbYv.mjs} +4 -4
- package/dist/.setup/targets-D1mAB5yO.mjs +3 -0
- package/dist/{thread-bindings-uudC_0TY.js → .setup/thread-bindings-CK5272V3.mjs} +6 -6
- package/dist/{thread-bindings.manager-BeUxc8nr.js → .setup/thread-bindings.manager-eexkKyrG.mjs} +14 -9
- package/dist/{thread-bindings.session-updates-BwkXpcy0.js → .setup/thread-bindings.session-updates-DCQq1WZ5.mjs} +1 -1
- package/dist/{thread-bindings.state-dDn-dwBw.js → .setup/thread-bindings.state-BThFQEga.mjs} +46 -14
- package/dist/{transcripts-source-VkgenQv-.js → .setup/transcripts-source-CuWYgayu.mjs} +62 -25
- package/dist/{typing-DuBg1U8Q.js → .setup/typing-BKZL5fGj.mjs} +2 -2
- package/dist/{voice-runtime-DMYDMkJx.js → .setup/voice-runtime-DHVQ2mFz.mjs} +529 -181
- package/dist/account-inspect-api.js +1 -1
- package/dist/action-runtime-api.js +1 -1
- package/dist/activities-api.js +1 -1
- package/dist/api.js +19 -19
- package/dist/channel-config-api.js +1 -1
- package/dist/channel-plugin-api.js +1 -1
- package/dist/contract-api.js +1 -1
- package/dist/directory-contract-api.js +1 -1
- package/dist/doctor-contract-api.js +4 -4
- package/dist/index.js +1 -1
- package/dist/runtime-api.js +22 -22
- package/dist/runtime-setter-api.js +1 -1
- package/dist/secret-contract-api.js +1 -1
- package/dist/security-audit-contract-api.js +1 -1
- package/dist/security-contract-api.js +1 -1
- package/dist/session-key-api.js +1 -1
- package/dist/setup-entry.js +2 -1
- package/dist/setup-plugin-api.js +1 -1
- package/dist/subagent-hooks-api.js +5 -4
- package/dist/thread-binding-api.js +1 -1
- package/dist/transcripts-source-api.js +1 -1
- package/node_modules/@types/node/README.md +1 -1
- package/node_modules/@types/node/buffer.d.ts +1 -0
- package/node_modules/@types/node/diagnostics_channel.d.ts +4 -4
- package/node_modules/@types/node/ffi.d.ts +1 -1
- package/node_modules/@types/node/http.d.ts +1 -1
- package/node_modules/@types/node/package.json +3 -3
- package/node_modules/@types/node/perf_hooks.d.ts +31 -19
- package/node_modules/@types/node/quic.d.ts +6 -4
- package/node_modules/@types/node/stream/web.d.ts +20 -0
- package/node_modules/@types/node/tls.d.ts +26 -15
- package/node_modules/@types/node/vfs.d.ts +7 -6
- package/node_modules/@types/node/zlib.d.ts +17 -0
- package/node_modules/discord-api-types/README.md +3 -2
- package/node_modules/discord-api-types/package.json +46 -46
- package/node_modules/discord-api-types/rest/v10/interactions.d.ts +1 -0
- package/node_modules/discord-api-types/rest/v10/interactions.d.ts.map +1 -1
- package/node_modules/discord-api-types/rest/v9/interactions.d.ts +1 -0
- package/node_modules/discord-api-types/rest/v9/interactions.d.ts.map +1 -1
- package/node_modules/libopus-wasm/CHANGELOG.md +15 -0
- package/node_modules/libopus-wasm/README.md +1 -1
- package/node_modules/libopus-wasm/dist/discordjs.d.ts.map +1 -1
- package/node_modules/libopus-wasm/dist/generated/libopus.generated.mjs +0 -0
- package/node_modules/libopus-wasm/dist/index.d.ts.map +1 -1
- package/node_modules/libopus-wasm/dist/index.js +37 -18
- package/node_modules/libopus-wasm/package.json +13 -13
- package/node_modules/typebox/build/compile/validator.d.mts +1 -1
- package/node_modules/typebox/build/compile/validator.mjs +1 -1
- package/node_modules/typebox/build/format/idna/idn-hostname.mjs +7 -5
- package/node_modules/typebox/build/format/iri.mjs +5 -1
- package/node_modules/typebox/build/guard/emit.mjs +2 -4
- package/node_modules/typebox/build/guard/guard.mjs +6 -18
- package/node_modules/typebox/build/guard/string.mjs +16 -24
- package/node_modules/typebox/build/schema/build.mjs +2 -2
- package/node_modules/typebox/build/schema/check.mjs +1 -1
- package/node_modules/typebox/build/schema/compile.d.mts +3 -2
- package/node_modules/typebox/build/schema/compile.mjs +8 -8
- package/node_modules/typebox/build/schema/engine/_context.d.mts +6 -7
- package/node_modules/typebox/build/schema/engine/_context.mjs +23 -15
- package/node_modules/typebox/build/schema/engine/_functions.d.mts +2 -2
- package/node_modules/typebox/build/schema/engine/_functions.mjs +1 -1
- package/node_modules/typebox/build/schema/engine/_reducer.d.mts +3 -3
- package/node_modules/typebox/build/schema/engine/_refine.d.mts +5 -5
- package/node_modules/typebox/build/schema/engine/_refine.mjs +4 -7
- package/node_modules/typebox/build/schema/engine/_stack.d.mts +34 -16
- package/node_modules/typebox/build/schema/engine/_stack.mjs +148 -104
- package/node_modules/typebox/build/schema/engine/additionalItems.d.mts +4 -4
- package/node_modules/typebox/build/schema/engine/additionalProperties.d.mts +8 -8
- package/node_modules/typebox/build/schema/engine/additionalProperties.mjs +26 -18
- package/node_modules/typebox/build/schema/engine/allOf.d.mts +4 -4
- package/node_modules/typebox/build/schema/engine/allOf.mjs +3 -3
- package/node_modules/typebox/build/schema/engine/anyOf.d.mts +4 -4
- package/node_modules/typebox/build/schema/engine/anyOf.mjs +5 -10
- package/node_modules/typebox/build/schema/engine/boolean.d.mts +4 -4
- package/node_modules/typebox/build/schema/engine/boolean.mjs +2 -6
- package/node_modules/typebox/build/schema/engine/const.d.mts +4 -4
- package/node_modules/typebox/build/schema/engine/const.mjs +2 -6
- package/node_modules/typebox/build/schema/engine/contains.d.mts +4 -4
- package/node_modules/typebox/build/schema/engine/contains.mjs +2 -6
- package/node_modules/typebox/build/schema/engine/dependencies.d.mts +4 -4
- package/node_modules/typebox/build/schema/engine/dependencies.mjs +3 -6
- package/node_modules/typebox/build/schema/engine/dependentRequired.d.mts +4 -4
- package/node_modules/typebox/build/schema/engine/dependentRequired.mjs +2 -6
- package/node_modules/typebox/build/schema/engine/dependentSchemas.d.mts +4 -4
- package/node_modules/typebox/build/schema/engine/dynamicRef.d.mts +4 -4
- package/node_modules/typebox/build/schema/engine/dynamicRef.mjs +11 -7
- package/node_modules/typebox/build/schema/engine/enum.d.mts +4 -4
- package/node_modules/typebox/build/schema/engine/enum.mjs +2 -6
- package/node_modules/typebox/build/schema/engine/exclusiveMaximum.d.mts +4 -4
- package/node_modules/typebox/build/schema/engine/exclusiveMaximum.mjs +2 -6
- package/node_modules/typebox/build/schema/engine/exclusiveMinimum.d.mts +4 -4
- package/node_modules/typebox/build/schema/engine/exclusiveMinimum.mjs +2 -6
- package/node_modules/typebox/build/schema/engine/format.d.mts +4 -4
- package/node_modules/typebox/build/schema/engine/format.mjs +2 -6
- package/node_modules/typebox/build/schema/engine/if.d.mts +4 -4
- package/node_modules/typebox/build/schema/engine/if.mjs +7 -15
- package/node_modules/typebox/build/schema/engine/items.d.mts +4 -4
- package/node_modules/typebox/build/schema/engine/items.mjs +1 -1
- package/node_modules/typebox/build/schema/engine/maxContains.d.mts +4 -4
- package/node_modules/typebox/build/schema/engine/maxContains.mjs +2 -6
- package/node_modules/typebox/build/schema/engine/maxItems.d.mts +4 -4
- package/node_modules/typebox/build/schema/engine/maxItems.mjs +2 -6
- package/node_modules/typebox/build/schema/engine/maxLength.d.mts +4 -4
- package/node_modules/typebox/build/schema/engine/maxLength.mjs +2 -6
- package/node_modules/typebox/build/schema/engine/maxProperties.d.mts +4 -4
- package/node_modules/typebox/build/schema/engine/maxProperties.mjs +2 -6
- package/node_modules/typebox/build/schema/engine/maximum.d.mts +4 -4
- package/node_modules/typebox/build/schema/engine/maximum.mjs +2 -6
- package/node_modules/typebox/build/schema/engine/minContains.d.mts +4 -4
- package/node_modules/typebox/build/schema/engine/minContains.mjs +2 -6
- package/node_modules/typebox/build/schema/engine/minItems.d.mts +5 -5
- package/node_modules/typebox/build/schema/engine/minItems.mjs +2 -6
- package/node_modules/typebox/build/schema/engine/minLength.d.mts +4 -4
- package/node_modules/typebox/build/schema/engine/minLength.mjs +2 -6
- package/node_modules/typebox/build/schema/engine/minProperties.d.mts +4 -4
- package/node_modules/typebox/build/schema/engine/minProperties.mjs +2 -6
- package/node_modules/typebox/build/schema/engine/minimum.d.mts +4 -4
- package/node_modules/typebox/build/schema/engine/minimum.mjs +2 -6
- package/node_modules/typebox/build/schema/engine/multipleOf.d.mts +4 -4
- package/node_modules/typebox/build/schema/engine/multipleOf.mjs +2 -6
- package/node_modules/typebox/build/schema/engine/not.d.mts +4 -4
- package/node_modules/typebox/build/schema/engine/not.mjs +4 -8
- package/node_modules/typebox/build/schema/engine/oneOf.d.mts +4 -4
- package/node_modules/typebox/build/schema/engine/oneOf.mjs +6 -11
- package/node_modules/typebox/build/schema/engine/pattern.d.mts +4 -4
- package/node_modules/typebox/build/schema/engine/pattern.mjs +3 -7
- package/node_modules/typebox/build/schema/engine/patternProperties.d.mts +4 -4
- package/node_modules/typebox/build/schema/engine/patternProperties.mjs +1 -1
- package/node_modules/typebox/build/schema/engine/prefixItems.d.mts +4 -4
- package/node_modules/typebox/build/schema/engine/prefixItems.mjs +1 -1
- package/node_modules/typebox/build/schema/engine/properties.d.mts +4 -4
- package/node_modules/typebox/build/schema/engine/properties.mjs +1 -1
- package/node_modules/typebox/build/schema/engine/propertyNames.d.mts +4 -4
- package/node_modules/typebox/build/schema/engine/propertyNames.mjs +4 -10
- package/node_modules/typebox/build/schema/engine/recursiveRef.d.mts +4 -4
- package/node_modules/typebox/build/schema/engine/recursiveRef.mjs +11 -7
- package/node_modules/typebox/build/schema/engine/ref.d.mts +4 -4
- package/node_modules/typebox/build/schema/engine/ref.mjs +19 -15
- package/node_modules/typebox/build/schema/engine/required.d.mts +4 -4
- package/node_modules/typebox/build/schema/engine/required.mjs +2 -6
- package/node_modules/typebox/build/schema/engine/schema.d.mts +7 -7
- package/node_modules/typebox/build/schema/engine/schema.mjs +137 -133
- package/node_modules/typebox/build/schema/engine/type.d.mts +4 -4
- package/node_modules/typebox/build/schema/engine/type.mjs +2 -6
- package/node_modules/typebox/build/schema/engine/unevaluatedItems.d.mts +4 -4
- package/node_modules/typebox/build/schema/engine/unevaluatedItems.mjs +5 -9
- package/node_modules/typebox/build/schema/engine/unevaluatedProperties.d.mts +4 -4
- package/node_modules/typebox/build/schema/engine/unevaluatedProperties.mjs +5 -9
- package/node_modules/typebox/build/schema/engine/uniqueItems.d.mts +4 -4
- package/node_modules/typebox/build/schema/engine/uniqueItems.mjs +2 -6
- package/node_modules/typebox/build/schema/errors.d.mts +2 -2
- package/node_modules/typebox/build/schema/errors.mjs +8 -14
- package/node_modules/typebox/build/schema/intern/index.d.mts +1 -0
- package/node_modules/typebox/build/schema/intern/index.mjs +1 -0
- package/node_modules/typebox/build/schema/intern/intern.d.mts +11 -0
- package/node_modules/typebox/build/schema/intern/intern.mjs +293 -0
- package/node_modules/typebox/build/schema/meta/draft_2019_09.d.mts +2 -0
- package/node_modules/typebox/build/schema/meta/draft_2019_09.mjs +288 -0
- package/node_modules/typebox/build/schema/meta/draft_2020_12.d.mts +2 -0
- package/node_modules/typebox/build/schema/meta/draft_2020_12.mjs +300 -0
- package/node_modules/typebox/build/schema/meta/draft_3.d.mts +2 -0
- package/node_modules/typebox/build/schema/meta/draft_3.mjs +143 -0
- package/node_modules/typebox/build/schema/meta/draft_4.d.mts +2 -0
- package/node_modules/typebox/build/schema/meta/draft_4.mjs +149 -0
- package/node_modules/typebox/build/schema/meta/draft_6.d.mts +2 -0
- package/node_modules/typebox/build/schema/meta/draft_6.mjs +155 -0
- package/node_modules/typebox/build/schema/meta/draft_7.d.mts +2 -0
- package/node_modules/typebox/build/schema/meta/draft_7.mjs +172 -0
- package/node_modules/typebox/build/schema/meta/index.d.mts +2 -0
- package/node_modules/typebox/build/schema/meta/index.mjs +2 -0
- package/node_modules/typebox/build/schema/meta/meta.d.mts +9 -0
- package/node_modules/typebox/build/schema/meta/meta.mjs +15 -0
- package/node_modules/typebox/build/schema/meta/schema.d.mts +6 -0
- package/node_modules/typebox/build/schema/meta/schema.mjs +1 -0
- package/node_modules/typebox/build/schema/parse.d.mts +1 -0
- package/node_modules/typebox/build/schema/parse.mjs +10 -5
- package/node_modules/typebox/build/schema/resolve/resolve.d.mts +8 -3
- package/node_modules/typebox/build/schema/resolve/resolve.mjs +268 -139
- package/node_modules/typebox/build/schema/schema.d.mts +2 -0
- package/node_modules/typebox/build/schema/schema.mjs +2 -0
- package/node_modules/typebox/build/value/errors/errors.d.mts +2 -12
- package/node_modules/typebox/build/value/errors/errors.mjs +2 -7
- package/node_modules/typebox/package.json +1 -1
- package/node_modules/typebox/readme.md +59 -89
- package/node_modules/undici-types/client.d.ts +8 -3
- package/node_modules/undici-types/connector.d.ts +1 -0
- package/node_modules/undici-types/cookies.d.ts +1 -1
- package/node_modules/undici-types/dispatcher.d.ts +3 -3
- package/node_modules/undici-types/errors.d.ts +10 -0
- package/node_modules/undici-types/fetch.d.ts +5 -1
- package/node_modules/undici-types/handlers.d.ts +2 -0
- package/node_modules/undici-types/interceptors.d.ts +1 -1
- package/node_modules/undici-types/mock-interceptor.d.ts +5 -1
- package/node_modules/undici-types/package.json +1 -1
- package/node_modules/undici-types/proxy-agent.d.ts +7 -0
- package/node_modules/zod/README.md +27 -0
- package/node_modules/zod/compile.cjs +77 -0
- package/node_modules/zod/compile.d.cts +1 -0
- package/node_modules/zod/compile.d.ts +1 -0
- package/node_modules/zod/compile.js +52 -0
- package/node_modules/zod/index.cjs +2 -2
- package/node_modules/zod/index.d.cts +1 -2
- package/node_modules/zod/index.d.ts +1 -2
- package/node_modules/zod/index.js +5 -2
- package/node_modules/zod/package.json +13 -2
- package/node_modules/zod/src/compile.ts +56 -0
- package/node_modules/zod/src/index.ts +5 -2
- package/node_modules/zod/src/v3/ZodError.ts +22 -12
- package/node_modules/zod/src/v3/tests/error.test.ts +35 -0
- package/node_modules/zod/src/v3/tests/intersection.test.ts +18 -0
- package/node_modules/zod/src/v3/tests/language-server.test.ts +1 -2
- package/node_modules/zod/src/v3/tests/object.test.ts +3 -6
- package/node_modules/zod/src/v3/tests/readonly.test.ts +0 -80
- package/node_modules/zod/src/v3/tests/string.test.ts +6 -0
- package/node_modules/zod/src/v3/types.ts +5 -5
- package/node_modules/zod/src/v4/classic/checks.ts +1 -0
- package/node_modules/zod/src/v4/classic/compat.ts +26 -18
- package/node_modules/zod/src/v4/classic/deep-partial.ts +76 -0
- package/node_modules/zod/src/v4/classic/errors.ts +59 -44
- package/node_modules/zod/src/v4/classic/external.ts +12 -9
- package/node_modules/zod/src/v4/classic/from-json-schema.ts +140 -78
- package/node_modules/zod/src/v4/classic/in-out.ts +45 -0
- package/node_modules/zod/src/v4/classic/index.ts +2 -2
- package/node_modules/zod/src/v4/classic/iso.ts +2 -72
- package/node_modules/zod/src/v4/classic/parse.ts +10 -4
- package/node_modules/zod/src/v4/classic/schemas.ts +452 -262
- package/node_modules/zod/src/v4/classic/tests/apply.test.ts +27 -0
- package/node_modules/zod/src/v4/classic/tests/array.test.ts +2 -2
- package/node_modules/zod/src/v4/classic/tests/assignability.test.ts +135 -0
- package/node_modules/zod/src/v4/classic/tests/bigint.test.ts +30 -1
- package/node_modules/zod/src/v4/classic/tests/catch.test.ts +278 -0
- package/node_modules/zod/src/v4/classic/tests/codec-examples.test.ts +1 -2
- package/node_modules/zod/src/v4/classic/tests/codec.test.ts +2 -1
- package/node_modules/zod/src/v4/classic/tests/continuability.test.ts +2 -2
- package/node_modules/zod/src/v4/classic/tests/credit-card.test.ts +76 -0
- package/node_modules/zod/src/v4/classic/tests/cyclic-data.test.ts +720 -0
- package/node_modules/zod/src/v4/classic/tests/date.test.ts +30 -0
- package/node_modules/zod/src/v4/classic/tests/datetime.test.ts +32 -18
- package/node_modules/zod/src/v4/classic/tests/deep-partial.test.ts +380 -0
- package/node_modules/zod/src/v4/classic/tests/default-locale.test.ts +32 -0
- package/node_modules/zod/src/v4/classic/tests/default.test.ts +46 -0
- package/node_modules/zod/src/v4/classic/tests/detached-methods.test.ts +31 -7
- package/node_modules/zod/src/v4/classic/tests/discriminated-unions.test.ts +155 -13
- package/node_modules/zod/src/v4/classic/tests/enum.test.ts +11 -0
- package/node_modules/zod/src/v4/classic/tests/error-utils.test.ts +112 -2
- package/node_modules/zod/src/v4/classic/tests/error.test.ts +274 -6
- package/node_modules/zod/src/v4/classic/tests/from-json-schema.test.ts +425 -10
- package/node_modules/zod/src/v4/classic/tests/function.test.ts +31 -0
- package/node_modules/zod/src/v4/classic/tests/global-config.test.ts +2 -9
- package/node_modules/zod/src/v4/classic/tests/hash.test.ts +1 -2
- package/node_modules/zod/src/v4/classic/tests/in-out.test.ts +159 -0
- package/node_modules/zod/src/v4/classic/tests/index.test.ts +21 -2
- package/node_modules/zod/src/v4/classic/tests/instance-footprint.test.ts +281 -0
- package/node_modules/zod/src/v4/classic/tests/instanceof.test.ts +47 -0
- package/node_modules/zod/src/v4/classic/tests/intersection.test.ts +136 -0
- package/node_modules/zod/src/v4/classic/tests/issue-schema.test.ts +183 -0
- package/node_modules/zod/src/v4/classic/tests/jitless-allows-eval.test.ts +3 -10
- package/node_modules/zod/src/v4/classic/tests/lazy.test.ts +36 -1
- package/node_modules/zod/src/v4/classic/tests/literal.test.ts +12 -1
- package/node_modules/zod/src/v4/classic/tests/map.test.ts +12 -0
- package/node_modules/zod/src/v4/classic/tests/number.test.ts +46 -9
- package/node_modules/zod/src/v4/classic/tests/object.test.ts +245 -12
- package/node_modules/zod/src/v4/classic/tests/optin-ladder.test.ts +234 -0
- package/node_modules/zod/src/v4/classic/tests/optional.test.ts +49 -16
- package/node_modules/zod/src/v4/classic/tests/partial.test.ts +51 -4
- package/node_modules/zod/src/v4/classic/tests/preprocess-types.test.ts +20 -2
- package/node_modules/zod/src/v4/classic/tests/readonly.test.ts +0 -68
- package/node_modules/zod/src/v4/classic/tests/record.test.ts +186 -18
- package/node_modules/zod/src/v4/classic/tests/recursive-types.test.ts +33 -2
- package/node_modules/zod/src/v4/classic/tests/redos.test.ts +68 -0
- package/node_modules/zod/src/v4/classic/tests/refine.test.ts +60 -0
- package/node_modules/zod/src/v4/classic/tests/set.test.ts +9 -0
- package/node_modules/zod/src/v4/classic/tests/string.test.ts +127 -5
- package/node_modules/zod/src/v4/classic/tests/stringbool.test.ts +18 -0
- package/node_modules/zod/src/v4/classic/tests/template-literal.test.ts +11 -2
- package/node_modules/zod/src/v4/classic/tests/to-json-schema.test.ts +1585 -173
- package/node_modules/zod/src/v4/classic/tests/tuple.test.ts +45 -30
- package/node_modules/zod/src/v4/classic/tests/union.test.ts +39 -2
- package/node_modules/zod/src/v4/classic/tests/validate.test.ts +76 -0
- package/node_modules/zod/src/v4/classic/tests/validations.test.ts +2 -2
- package/node_modules/zod/src/v4/core/api.ts +48 -12
- package/node_modules/zod/src/v4/core/checks.ts +57 -44
- package/node_modules/zod/src/v4/core/compile.ts +2188 -0
- package/node_modules/zod/src/v4/core/core.ts +98 -19
- package/node_modules/zod/src/v4/core/doc.ts +11 -7
- package/node_modules/zod/src/v4/core/errors.ts +115 -24
- package/node_modules/zod/src/v4/core/index.ts +3 -0
- package/node_modules/zod/src/v4/core/json-schema-generator.ts +6 -1
- package/node_modules/zod/src/v4/core/json-schema-processors.ts +257 -93
- package/node_modules/zod/src/v4/core/json-schema.ts +2 -1
- package/node_modules/zod/src/v4/core/memoizer.ts +284 -0
- package/node_modules/zod/src/v4/core/parse.ts +131 -38
- package/node_modules/zod/src/v4/core/regexes.ts +30 -13
- package/node_modules/zod/src/v4/core/registries.ts +2 -2
- package/node_modules/zod/src/v4/core/schemas.ts +759 -461
- package/node_modules/zod/src/v4/core/tests/compile-differential.test.ts +969 -0
- package/node_modules/zod/src/v4/core/tests/compile-global.test.ts +89 -0
- package/node_modules/zod/src/v4/core/tests/compile-off-by-default.test.ts +26 -0
- package/node_modules/zod/src/v4/core/tests/compile-stats.test.ts +34 -0
- package/node_modules/zod/src/v4/core/tests/compile.test.ts +1639 -0
- package/node_modules/zod/src/v4/core/tests/locales/el.test.ts +1 -2
- package/node_modules/zod/src/v4/core/tests/locales/es.test.ts +1 -2
- package/node_modules/zod/src/v4/core/tests/locales/fr.test.ts +3 -3
- package/node_modules/zod/src/v4/core/tests/locales/parity.test.ts +42 -0
- package/node_modules/zod/src/v4/core/tests/locales/tk.test.ts +69 -0
- package/node_modules/zod/src/v4/core/tests/treeshake.test.ts +51 -0
- package/node_modules/zod/src/v4/core/tests/url-no-canparse.test.ts +31 -0
- package/node_modules/zod/src/v4/core/to-json-schema.ts +275 -42
- package/node_modules/zod/src/v4/core/util.ts +268 -42
- package/node_modules/zod/src/v4/core/versions.ts +2 -2
- package/node_modules/zod/src/v4/core/visit.ts +193 -0
- package/node_modules/zod/src/v4/index.ts +3 -3
- package/node_modules/zod/src/v4/locales/ar.ts +3 -0
- package/node_modules/zod/src/v4/locales/az.ts +3 -0
- package/node_modules/zod/src/v4/locales/be.ts +10 -0
- package/node_modules/zod/src/v4/locales/bg.ts +3 -0
- package/node_modules/zod/src/v4/locales/bn.ts +121 -0
- package/node_modules/zod/src/v4/locales/ca.ts +3 -0
- package/node_modules/zod/src/v4/locales/ckb.ts +138 -0
- package/node_modules/zod/src/v4/locales/cs.ts +3 -0
- package/node_modules/zod/src/v4/locales/da.ts +5 -2
- package/node_modules/zod/src/v4/locales/de.ts +3 -0
- package/node_modules/zod/src/v4/locales/el.ts +1 -0
- package/node_modules/zod/src/v4/locales/en.ts +15 -4
- package/node_modules/zod/src/v4/locales/eo.ts +3 -0
- package/node_modules/zod/src/v4/locales/es.ts +2 -0
- package/node_modules/zod/src/v4/locales/fa.ts +3 -0
- package/node_modules/zod/src/v4/locales/fi.ts +3 -0
- package/node_modules/zod/src/v4/locales/fr-CA.ts +3 -0
- package/node_modules/zod/src/v4/locales/fr.ts +19 -14
- package/node_modules/zod/src/v4/locales/gu.ts +121 -0
- package/node_modules/zod/src/v4/locales/he.ts +6 -1
- package/node_modules/zod/src/v4/locales/hi.ts +124 -0
- package/node_modules/zod/src/v4/locales/hr.ts +2 -0
- package/node_modules/zod/src/v4/locales/hu.ts +3 -0
- package/node_modules/zod/src/v4/locales/hy.ts +9 -0
- package/node_modules/zod/src/v4/locales/id.ts +3 -0
- package/node_modules/zod/src/v4/locales/index.ts +10 -0
- package/node_modules/zod/src/v4/locales/is.ts +3 -0
- package/node_modules/zod/src/v4/locales/it.ts +3 -0
- package/node_modules/zod/src/v4/locales/ja.ts +3 -0
- package/node_modules/zod/src/v4/locales/ka.ts +3 -0
- package/node_modules/zod/src/v4/locales/km.ts +3 -0
- package/node_modules/zod/src/v4/locales/kn.ts +124 -0
- package/node_modules/zod/src/v4/locales/ko.ts +3 -0
- package/node_modules/zod/src/v4/locales/lt.ts +2 -0
- package/node_modules/zod/src/v4/locales/mk.ts +3 -0
- package/node_modules/zod/src/v4/locales/ms.ts +3 -0
- package/node_modules/zod/src/v4/locales/ne.ts +126 -0
- package/node_modules/zod/src/v4/locales/nl.ts +3 -0
- package/node_modules/zod/src/v4/locales/nn.ts +119 -0
- package/node_modules/zod/src/v4/locales/no.ts +5 -2
- package/node_modules/zod/src/v4/locales/ota.ts +3 -0
- package/node_modules/zod/src/v4/locales/pl.ts +3 -0
- package/node_modules/zod/src/v4/locales/ps.ts +3 -0
- package/node_modules/zod/src/v4/locales/pt-BR.ts +159 -0
- package/node_modules/zod/src/v4/locales/pt.ts +99 -58
- package/node_modules/zod/src/v4/locales/ro.ts +1 -0
- package/node_modules/zod/src/v4/locales/ru.ts +10 -0
- package/node_modules/zod/src/v4/locales/sk.ts +121 -0
- package/node_modules/zod/src/v4/locales/sl.ts +3 -0
- package/node_modules/zod/src/v4/locales/sv.ts +5 -2
- package/node_modules/zod/src/v4/locales/ta.ts +3 -0
- package/node_modules/zod/src/v4/locales/th.ts +3 -0
- package/node_modules/zod/src/v4/locales/tk.ts +111 -0
- package/node_modules/zod/src/v4/locales/tr.ts +3 -0
- package/node_modules/zod/src/v4/locales/uk.ts +3 -0
- package/node_modules/zod/src/v4/locales/ur.ts +3 -0
- package/node_modules/zod/src/v4/locales/uz.ts +1 -0
- package/node_modules/zod/src/v4/locales/vi.ts +3 -0
- package/node_modules/zod/src/v4/locales/yo.ts +3 -0
- package/node_modules/zod/src/v4/locales/zh-CN.ts +3 -0
- package/node_modules/zod/src/v4/locales/zh-TW.ts +3 -0
- package/node_modules/zod/src/v4/mini/checks.ts +1 -0
- package/node_modules/zod/src/v4/mini/deep-partial.ts +73 -0
- package/node_modules/zod/src/v4/mini/external.ts +10 -1
- package/node_modules/zod/src/v4/mini/in-out.ts +45 -0
- package/node_modules/zod/src/v4/mini/parse.ts +2 -0
- package/node_modules/zod/src/v4/mini/schemas.ts +135 -56
- package/node_modules/zod/src/v4/mini/tests/apply.test.ts +33 -0
- package/node_modules/zod/src/v4/mini/tests/assignability.test.ts +62 -1
- package/node_modules/zod/src/v4/mini/tests/checks.test.ts +14 -0
- package/node_modules/zod/src/v4/mini/tests/codec.test.ts +35 -1
- package/node_modules/zod/src/v4/mini/tests/cyclic-data.test.ts +84 -0
- package/node_modules/zod/src/v4/mini/tests/deep-partial.test.ts +54 -0
- package/node_modules/zod/src/v4/mini/tests/error.test.ts +23 -4
- package/node_modules/zod/src/v4/mini/tests/functions.test.ts +9 -0
- package/node_modules/zod/src/v4/mini/tests/index.test.ts +72 -5
- package/node_modules/zod/src/v4/mini/tests/number.test.ts +14 -0
- package/node_modules/zod/src/v4/mini/tests/object.test.ts +65 -0
- package/node_modules/zod/src/v4/mini/tests/string.test.ts +21 -0
- package/node_modules/zod/v3/ZodError.cjs +22 -12
- package/node_modules/zod/v3/ZodError.d.cts +1 -1
- package/node_modules/zod/v3/ZodError.d.ts +1 -1
- package/node_modules/zod/v3/ZodError.js +22 -12
- package/node_modules/zod/v3/types.cjs +7 -5
- package/node_modules/zod/v3/types.js +7 -5
- package/node_modules/zod/v4/classic/checks.cjs +2 -1
- package/node_modules/zod/v4/classic/checks.d.cts +1 -1
- package/node_modules/zod/v4/classic/checks.d.ts +1 -1
- package/node_modules/zod/v4/classic/checks.js +1 -1
- package/node_modules/zod/v4/classic/compat.d.cts +9 -11
- package/node_modules/zod/v4/classic/compat.d.ts +9 -11
- package/node_modules/zod/v4/classic/deep-partial.cjs +39 -0
- package/node_modules/zod/v4/classic/deep-partial.d.cts +14 -0
- package/node_modules/zod/v4/classic/deep-partial.d.ts +14 -0
- package/node_modules/zod/v4/classic/deep-partial.js +13 -0
- package/node_modules/zod/v4/classic/errors.cjs +43 -34
- package/node_modules/zod/v4/classic/errors.d.cts +3 -4
- package/node_modules/zod/v4/classic/errors.d.ts +3 -4
- package/node_modules/zod/v4/classic/errors.js +43 -34
- package/node_modules/zod/v4/classic/external.cjs +30 -27
- package/node_modules/zod/v4/classic/external.d.cts +5 -2
- package/node_modules/zod/v4/classic/external.d.ts +5 -2
- package/node_modules/zod/v4/classic/external.js +5 -8
- package/node_modules/zod/v4/classic/from-json-schema.cjs +136 -75
- package/node_modules/zod/v4/classic/from-json-schema.js +136 -75
- package/node_modules/zod/v4/classic/in-out.cjs +63 -0
- package/node_modules/zod/v4/classic/in-out.d.cts +8 -0
- package/node_modules/zod/v4/classic/in-out.d.ts +8 -0
- package/node_modules/zod/v4/classic/in-out.js +36 -0
- package/node_modules/zod/v4/classic/index.cjs +2 -2
- package/node_modules/zod/v4/classic/index.d.cts +1 -2
- package/node_modules/zod/v4/classic/index.d.ts +1 -2
- package/node_modules/zod/v4/classic/index.js +2 -2
- package/node_modules/zod/v4/classic/iso.cjs +11 -22
- package/node_modules/zod/v4/classic/iso.d.cts +2 -17
- package/node_modules/zod/v4/classic/iso.d.ts +2 -17
- package/node_modules/zod/v4/classic/iso.js +2 -17
- package/node_modules/zod/v4/classic/parse.cjs +4 -1
- package/node_modules/zod/v4/classic/parse.d.cts +17 -4
- package/node_modules/zod/v4/classic/parse.d.ts +17 -4
- package/node_modules/zod/v4/classic/parse.js +1 -0
- package/node_modules/zod/v4/classic/schemas.cjs +498 -398
- package/node_modules/zod/v4/classic/schemas.d.cts +53 -18
- package/node_modules/zod/v4/classic/schemas.d.ts +53 -18
- package/node_modules/zod/v4/classic/schemas.js +492 -396
- package/node_modules/zod/v4/core/api.cjs +23 -4
- package/node_modules/zod/v4/core/api.d.cts +13 -9
- package/node_modules/zod/v4/core/api.d.ts +13 -9
- package/node_modules/zod/v4/core/api.js +21 -4
- package/node_modules/zod/v4/core/checks.cjs +37 -31
- package/node_modules/zod/v4/core/checks.d.cts +13 -13
- package/node_modules/zod/v4/core/checks.d.ts +13 -13
- package/node_modules/zod/v4/core/checks.js +37 -31
- package/node_modules/zod/v4/core/compile.cjs +1813 -0
- package/node_modules/zod/v4/core/compile.d.cts +51 -0
- package/node_modules/zod/v4/core/compile.d.ts +51 -0
- package/node_modules/zod/v4/core/compile.js +1783 -0
- package/node_modules/zod/v4/core/core.cjs +81 -18
- package/node_modules/zod/v4/core/core.d.cts +16 -4
- package/node_modules/zod/v4/core/core.d.ts +16 -4
- package/node_modules/zod/v4/core/core.js +82 -19
- package/node_modules/zod/v4/core/doc.cjs +5 -7
- package/node_modules/zod/v4/core/doc.d.cts +3 -1
- package/node_modules/zod/v4/core/doc.d.ts +3 -1
- package/node_modules/zod/v4/core/doc.js +5 -7
- package/node_modules/zod/v4/core/errors.cjs +110 -25
- package/node_modules/zod/v4/core/errors.d.cts +4 -0
- package/node_modules/zod/v4/core/errors.d.ts +4 -0
- package/node_modules/zod/v4/core/errors.js +110 -25
- package/node_modules/zod/v4/core/index.cjs +5 -1
- package/node_modules/zod/v4/core/index.d.cts +3 -0
- package/node_modules/zod/v4/core/index.d.ts +3 -0
- package/node_modules/zod/v4/core/index.js +3 -0
- package/node_modules/zod/v4/core/json-schema-generator.cjs +4 -0
- package/node_modules/zod/v4/core/json-schema-generator.d.cts +2 -2
- package/node_modules/zod/v4/core/json-schema-generator.d.ts +2 -2
- package/node_modules/zod/v4/core/json-schema-generator.js +4 -0
- package/node_modules/zod/v4/core/json-schema-processors.cjs +264 -95
- package/node_modules/zod/v4/core/json-schema-processors.js +243 -97
- package/node_modules/zod/v4/core/json-schema.d.cts +2 -1
- package/node_modules/zod/v4/core/json-schema.d.ts +2 -1
- package/node_modules/zod/v4/core/memoizer.cjs +272 -0
- package/node_modules/zod/v4/core/memoizer.d.cts +15 -0
- package/node_modules/zod/v4/core/memoizer.d.ts +15 -0
- package/node_modules/zod/v4/core/memoizer.js +265 -0
- package/node_modules/zod/v4/core/parse.cjs +96 -34
- package/node_modules/zod/v4/core/parse.d.cts +14 -11
- package/node_modules/zod/v4/core/parse.d.ts +14 -11
- package/node_modules/zod/v4/core/parse.js +94 -33
- package/node_modules/zod/v4/core/regexes.cjs +27 -15
- package/node_modules/zod/v4/core/regexes.d.cts +2 -0
- package/node_modules/zod/v4/core/regexes.d.ts +2 -0
- package/node_modules/zod/v4/core/regexes.js +24 -13
- package/node_modules/zod/v4/core/registries.js +2 -2
- package/node_modules/zod/v4/core/schemas.cjs +537 -326
- package/node_modules/zod/v4/core/schemas.d.cts +100 -31
- package/node_modules/zod/v4/core/schemas.d.ts +100 -31
- package/node_modules/zod/v4/core/schemas.js +526 -325
- package/node_modules/zod/v4/core/to-json-schema.cjs +242 -39
- package/node_modules/zod/v4/core/to-json-schema.d.cts +42 -3
- package/node_modules/zod/v4/core/to-json-schema.d.ts +42 -3
- package/node_modules/zod/v4/core/to-json-schema.js +241 -39
- package/node_modules/zod/v4/core/util.cjs +212 -31
- package/node_modules/zod/v4/core/util.d.cts +58 -1
- package/node_modules/zod/v4/core/util.d.ts +58 -1
- package/node_modules/zod/v4/core/util.js +202 -30
- package/node_modules/zod/v4/core/versions.cjs +2 -2
- package/node_modules/zod/v4/core/versions.d.cts +1 -1
- package/node_modules/zod/v4/core/versions.d.ts +1 -1
- package/node_modules/zod/v4/core/versions.js +2 -2
- package/node_modules/zod/v4/core/visit.cjs +195 -0
- package/node_modules/zod/v4/core/visit.d.cts +30 -0
- package/node_modules/zod/v4/core/visit.d.ts +30 -0
- package/node_modules/zod/v4/core/visit.js +169 -0
- package/node_modules/zod/v4/index.cjs +15 -5
- package/node_modules/zod/v4/index.d.cts +2 -2
- package/node_modules/zod/v4/index.d.ts +2 -2
- package/node_modules/zod/v4/index.js +3 -2
- package/node_modules/zod/v4/locales/ar.cjs +3 -0
- package/node_modules/zod/v4/locales/ar.js +3 -0
- package/node_modules/zod/v4/locales/az.cjs +3 -0
- package/node_modules/zod/v4/locales/az.js +3 -0
- package/node_modules/zod/v4/locales/be.cjs +10 -0
- package/node_modules/zod/v4/locales/be.js +10 -0
- package/node_modules/zod/v4/locales/bg.cjs +3 -0
- package/node_modules/zod/v4/locales/bg.js +3 -0
- package/node_modules/zod/v4/locales/bn.cjs +138 -0
- package/node_modules/zod/v4/locales/bn.d.cts +5 -0
- package/node_modules/zod/v4/locales/bn.d.ts +4 -0
- package/node_modules/zod/v4/locales/bn.js +111 -0
- package/node_modules/zod/v4/locales/ca.cjs +3 -0
- package/node_modules/zod/v4/locales/ca.js +3 -0
- package/node_modules/zod/v4/locales/ckb.cjs +158 -0
- package/node_modules/zod/v4/locales/ckb.d.cts +5 -0
- package/node_modules/zod/v4/locales/ckb.d.ts +4 -0
- package/node_modules/zod/v4/locales/ckb.js +131 -0
- package/node_modules/zod/v4/locales/cs.cjs +3 -0
- package/node_modules/zod/v4/locales/cs.js +3 -0
- package/node_modules/zod/v4/locales/da.cjs +5 -2
- package/node_modules/zod/v4/locales/da.js +5 -2
- package/node_modules/zod/v4/locales/de.cjs +3 -0
- package/node_modules/zod/v4/locales/de.js +3 -0
- package/node_modules/zod/v4/locales/el.cjs +1 -0
- package/node_modules/zod/v4/locales/el.js +1 -0
- package/node_modules/zod/v4/locales/en.cjs +14 -4
- package/node_modules/zod/v4/locales/en.js +14 -4
- package/node_modules/zod/v4/locales/eo.cjs +3 -0
- package/node_modules/zod/v4/locales/eo.js +3 -0
- package/node_modules/zod/v4/locales/es.cjs +2 -0
- package/node_modules/zod/v4/locales/es.js +2 -0
- package/node_modules/zod/v4/locales/fa.cjs +3 -0
- package/node_modules/zod/v4/locales/fa.js +3 -0
- package/node_modules/zod/v4/locales/fi.cjs +3 -0
- package/node_modules/zod/v4/locales/fi.js +3 -0
- package/node_modules/zod/v4/locales/fr-CA.cjs +3 -0
- package/node_modules/zod/v4/locales/fr-CA.js +3 -0
- package/node_modules/zod/v4/locales/fr.cjs +16 -14
- package/node_modules/zod/v4/locales/fr.js +16 -14
- package/node_modules/zod/v4/locales/gu.cjs +138 -0
- package/node_modules/zod/v4/locales/gu.d.cts +5 -0
- package/node_modules/zod/v4/locales/gu.d.ts +4 -0
- package/node_modules/zod/v4/locales/gu.js +111 -0
- package/node_modules/zod/v4/locales/he.cjs +5 -0
- package/node_modules/zod/v4/locales/he.js +5 -0
- package/node_modules/zod/v4/locales/hi.cjs +136 -0
- package/node_modules/zod/v4/locales/hi.d.cts +5 -0
- package/node_modules/zod/v4/locales/hi.d.ts +4 -0
- package/node_modules/zod/v4/locales/hi.js +109 -0
- package/node_modules/zod/v4/locales/hr.cjs +2 -0
- package/node_modules/zod/v4/locales/hr.js +2 -0
- package/node_modules/zod/v4/locales/hu.cjs +3 -0
- package/node_modules/zod/v4/locales/hu.js +3 -0
- package/node_modules/zod/v4/locales/hy.cjs +9 -0
- package/node_modules/zod/v4/locales/hy.js +9 -0
- package/node_modules/zod/v4/locales/id.cjs +3 -0
- package/node_modules/zod/v4/locales/id.js +3 -0
- package/node_modules/zod/v4/locales/index.cjs +22 -2
- package/node_modules/zod/v4/locales/index.d.cts +10 -0
- package/node_modules/zod/v4/locales/index.d.ts +10 -0
- package/node_modules/zod/v4/locales/index.js +10 -0
- package/node_modules/zod/v4/locales/is.cjs +3 -0
- package/node_modules/zod/v4/locales/is.js +3 -0
- package/node_modules/zod/v4/locales/it.cjs +3 -0
- package/node_modules/zod/v4/locales/it.js +3 -0
- package/node_modules/zod/v4/locales/ja.cjs +3 -0
- package/node_modules/zod/v4/locales/ja.js +3 -0
- package/node_modules/zod/v4/locales/ka.cjs +3 -0
- package/node_modules/zod/v4/locales/ka.js +3 -0
- package/node_modules/zod/v4/locales/km.cjs +3 -0
- package/node_modules/zod/v4/locales/km.js +3 -0
- package/node_modules/zod/v4/locales/kn.cjs +141 -0
- package/node_modules/zod/v4/locales/kn.d.cts +5 -0
- package/node_modules/zod/v4/locales/kn.d.ts +4 -0
- package/node_modules/zod/v4/locales/kn.js +114 -0
- package/node_modules/zod/v4/locales/ko.cjs +3 -0
- package/node_modules/zod/v4/locales/ko.js +3 -0
- package/node_modules/zod/v4/locales/lt.cjs +2 -0
- package/node_modules/zod/v4/locales/lt.js +2 -0
- package/node_modules/zod/v4/locales/mk.cjs +3 -0
- package/node_modules/zod/v4/locales/mk.js +3 -0
- package/node_modules/zod/v4/locales/ms.cjs +3 -0
- package/node_modules/zod/v4/locales/ms.js +3 -0
- package/node_modules/zod/v4/locales/ne.cjs +136 -0
- package/node_modules/zod/v4/locales/ne.d.cts +5 -0
- package/node_modules/zod/v4/locales/ne.d.ts +4 -0
- package/node_modules/zod/v4/locales/ne.js +109 -0
- package/node_modules/zod/v4/locales/nl.cjs +3 -0
- package/node_modules/zod/v4/locales/nl.js +3 -0
- package/node_modules/zod/v4/locales/nn.cjs +138 -0
- package/node_modules/zod/v4/locales/nn.d.cts +5 -0
- package/node_modules/zod/v4/locales/nn.d.ts +4 -0
- package/node_modules/zod/v4/locales/nn.js +111 -0
- package/node_modules/zod/v4/locales/no.cjs +5 -2
- package/node_modules/zod/v4/locales/no.js +5 -2
- package/node_modules/zod/v4/locales/ota.cjs +3 -0
- package/node_modules/zod/v4/locales/ota.js +3 -0
- package/node_modules/zod/v4/locales/pl.cjs +3 -0
- package/node_modules/zod/v4/locales/pl.js +3 -0
- package/node_modules/zod/v4/locales/ps.cjs +3 -0
- package/node_modules/zod/v4/locales/ps.js +3 -0
- package/node_modules/zod/v4/locales/pt-BR.cjs +168 -0
- package/node_modules/zod/v4/locales/pt-BR.d.cts +5 -0
- package/node_modules/zod/v4/locales/pt-BR.d.ts +4 -0
- package/node_modules/zod/v4/locales/pt-BR.js +141 -0
- package/node_modules/zod/v4/locales/pt.cjs +87 -55
- package/node_modules/zod/v4/locales/pt.js +87 -55
- package/node_modules/zod/v4/locales/ro.cjs +1 -0
- package/node_modules/zod/v4/locales/ro.js +1 -0
- package/node_modules/zod/v4/locales/ru.cjs +10 -0
- package/node_modules/zod/v4/locales/ru.js +10 -0
- package/node_modules/zod/v4/locales/sk.cjs +141 -0
- package/node_modules/zod/v4/locales/sk.d.cts +5 -0
- package/node_modules/zod/v4/locales/sk.d.ts +4 -0
- package/node_modules/zod/v4/locales/sk.js +114 -0
- package/node_modules/zod/v4/locales/sl.cjs +3 -0
- package/node_modules/zod/v4/locales/sl.js +3 -0
- package/node_modules/zod/v4/locales/sv.cjs +5 -2
- package/node_modules/zod/v4/locales/sv.js +5 -2
- package/node_modules/zod/v4/locales/ta.cjs +3 -0
- package/node_modules/zod/v4/locales/ta.js +3 -0
- package/node_modules/zod/v4/locales/th.cjs +3 -0
- package/node_modules/zod/v4/locales/th.js +3 -0
- package/node_modules/zod/v4/locales/tk.cjs +132 -0
- package/node_modules/zod/v4/locales/tk.d.cts +5 -0
- package/node_modules/zod/v4/locales/tk.d.ts +4 -0
- package/node_modules/zod/v4/locales/tk.js +105 -0
- package/node_modules/zod/v4/locales/tr.cjs +3 -0
- package/node_modules/zod/v4/locales/tr.js +3 -0
- package/node_modules/zod/v4/locales/uk.cjs +3 -0
- package/node_modules/zod/v4/locales/uk.js +3 -0
- package/node_modules/zod/v4/locales/ur.cjs +3 -0
- package/node_modules/zod/v4/locales/ur.js +3 -0
- package/node_modules/zod/v4/locales/uz.cjs +1 -0
- package/node_modules/zod/v4/locales/uz.js +1 -0
- package/node_modules/zod/v4/locales/vi.cjs +3 -0
- package/node_modules/zod/v4/locales/vi.js +3 -0
- package/node_modules/zod/v4/locales/yo.cjs +3 -0
- package/node_modules/zod/v4/locales/yo.js +3 -0
- package/node_modules/zod/v4/locales/zh-CN.cjs +3 -0
- package/node_modules/zod/v4/locales/zh-CN.js +3 -0
- package/node_modules/zod/v4/locales/zh-TW.cjs +3 -0
- package/node_modules/zod/v4/locales/zh-TW.js +3 -0
- package/node_modules/zod/v4/mini/checks.cjs +2 -1
- package/node_modules/zod/v4/mini/checks.d.cts +1 -1
- package/node_modules/zod/v4/mini/checks.d.ts +1 -1
- package/node_modules/zod/v4/mini/checks.js +1 -1
- package/node_modules/zod/v4/mini/deep-partial.cjs +39 -0
- package/node_modules/zod/v4/mini/deep-partial.d.cts +14 -0
- package/node_modules/zod/v4/mini/deep-partial.d.ts +14 -0
- package/node_modules/zod/v4/mini/deep-partial.js +13 -0
- package/node_modules/zod/v4/mini/external.cjs +12 -1
- package/node_modules/zod/v4/mini/external.d.cts +5 -2
- package/node_modules/zod/v4/mini/external.d.ts +5 -2
- package/node_modules/zod/v4/mini/external.js +3 -1
- package/node_modules/zod/v4/mini/in-out.cjs +63 -0
- package/node_modules/zod/v4/mini/in-out.d.cts +8 -0
- package/node_modules/zod/v4/mini/in-out.d.ts +8 -0
- package/node_modules/zod/v4/mini/in-out.js +36 -0
- package/node_modules/zod/v4/mini/parse.cjs +3 -1
- package/node_modules/zod/v4/mini/parse.d.cts +1 -1
- package/node_modules/zod/v4/mini/parse.d.ts +1 -1
- package/node_modules/zod/v4/mini/parse.js +1 -1
- package/node_modules/zod/v4/mini/schemas.cjs +75 -47
- package/node_modules/zod/v4/mini/schemas.d.cts +43 -13
- package/node_modules/zod/v4/mini/schemas.d.ts +43 -13
- package/node_modules/zod/v4/mini/schemas.js +71 -45
- package/openclaw.plugin.json +3 -4
- package/package.json +10 -8
- package/dist/channel-type-CVLZyGYS.js +0 -7
- package/dist/outbound-components-DrlHcWfM.js +0 -100
- package/dist/provider.runtime-CqfE-RvC.js +0 -2
- package/dist/targets-Cm6aV9nJ.js +0 -3
- package/node_modules/discord-api-types/CHANGELOG.md +0 -2514
- package/node_modules/discord-api-types/scripts/versions.mjs +0 -46
- package/node_modules/zod/src/v4/core/config.ts +0 -15
- /package/dist/{accounts-CwJQoLjM.js → .setup/accounts-CwJQoLjM.mjs} +0 -0
- /package/dist/{active-turn-thread-route-fmHl1HNd.js → .setup/active-turn-thread-route-fmHl1HNd.mjs} +0 -0
- /package/dist/{agent-components.runtime-CEPrf2SY.js → .setup/agent-components.runtime-CEPrf2SY.mjs} +0 -0
- /package/dist/{channel-access-C12aDZ0p.js → .setup/channel-access-C12aDZ0p.mjs} +0 -0
- /package/dist/{command-deploy-store-DFkBTViB.js → .setup/command-deploy-store-DFkBTViB.mjs} +0 -0
- /package/dist/{command-owners-D78sAoOz.js → .setup/command-owners-D78sAoOz.mjs} +0 -0
- /package/dist/{doctor-contract-Co5vRCZ6.js → .setup/doctor-contract-Co5vRCZ6.mjs} +0 -0
- /package/dist/{message-handler.history-CJOsN9w5.js → .setup/message-handler.history-CJOsN9w5.mjs} +0 -0
- /package/dist/{model-picker-preference-primitives-BHT1LkR_.js → .setup/model-picker-preference-primitives-BHT1LkR_.mjs} +0 -0
- /package/dist/{preflight-audio-DrnqFA8U.js → .setup/preflight-audio-DrnqFA8U.mjs} +0 -0
- /package/dist/{presence-cache-dYSHPWMx.js → .setup/presence-cache-dYSHPWMx.mjs} +0 -0
- /package/dist/{runtime-DgnVQ7zW.js → .setup/runtime-DgnVQ7zW.mjs} +0 -0
- /package/dist/{secret-config-contract-DFu9hfU8.js → .setup/secret-config-contract-DFu9hfU8.mjs} +0 -0
- /package/dist/{security-contract-DSHk7I2w.js → .setup/security-contract-DSHk7I2w.mjs} +0 -0
- /package/dist/{security-doctor-nGgPm65L.js → .setup/security-doctor-nGgPm65L.mjs} +0 -0
- /package/dist/{session-contract-BO5tlIdl.js → .setup/session-contract-BO5tlIdl.mjs} +0 -0
- /package/dist/{session-key-normalization-wJgsKPNF.js → .setup/session-key-normalization-wJgsKPNF.mjs} +0 -0
- /package/dist/{thread-binding-api-BDZJD4na.js → .setup/thread-binding-api-BDZJD4na.mjs} +0 -0
- /package/dist/{timeouts-D86uWLt_.js → .setup/timeouts-D86uWLt_.mjs} +0 -0
|
@@ -1,29 +1,29 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { C as parseDiscordActivityCustomIdForInteraction, D as parseDiscordModalCustomIdForInteraction, E as parseDiscordModalCustomId, O as decodeCustomIdComponent, T as parseDiscordComponentCustomIdForInteraction, c as parseExecApprovalData, k as encodeCustomIdComponent, o as parseDiscordQuestionData, w as parseDiscordComponentCustomId, y as buildDiscordActivityCustomId } from "./components-
|
|
3
|
-
import {
|
|
4
|
-
import { c as resolveDiscordAccount, f as resolveDiscordAccountDmPolicy, h as resolveDiscordToken, l as resolveDiscordAccountAllowFrom, m as normalizeDiscordToken, o as mergeDiscordAccountConfig, p as resolveDiscordMaxLinesPerMessage } from "./accounts-CwJQoLjM.
|
|
5
|
-
import { a as
|
|
6
|
-
import { t as getDiscordRuntime } from "./runtime-DgnVQ7zW.
|
|
7
|
-
import { a as isDiscordRateLimitResponseBody, o as summarizeDiscordResponseBody } from "./api-
|
|
8
|
-
import { o as chunkDiscordTextWithMode } from "./retry-
|
|
9
|
-
import { B as validateDiscordProxyUrl, G as unregisterGateway, P as createDiscordRestClient, R as DISCORD_REST_TIMEOUT_MS, V as withValidatedDiscordProxy, W as registerGateway, b as canViewDiscordGuildChannel, w as hasAnyChannelPermissionDiscord } from "./send.shared-
|
|
10
|
-
import { o as formatMention, t as sendMessageDiscord } from "./send.outbound-
|
|
11
|
-
import {
|
|
12
|
-
import {
|
|
13
|
-
import {
|
|
14
|
-
import {
|
|
15
|
-
import {
|
|
16
|
-
import {
|
|
17
|
-
import {
|
|
18
|
-
import { c as
|
|
19
|
-
import {
|
|
20
|
-
import {
|
|
21
|
-
import { t as
|
|
22
|
-
import {
|
|
23
|
-
import { a as
|
|
24
|
-
import {
|
|
25
|
-
import {
|
|
26
|
-
import { t as
|
|
1
|
+
import { D as Message, E as Guild, G as Row, J as StringSelectMenu, L as Button, O as User, P as Modal, Q as BaseMessageInteractiveComponent, T as CommandWithSubcommands, Y as TextDisplay, a as MessageCreateListener, c as PresenceUpdateListener, d as ThreadDeleteListener, f as ThreadUpdateListener, h as Plugin, i as InteractionCreateListener, k as hasDiscordV2Components, l as ReadyListener, m as Client, n as GuildCreateListener, o as MessageReactionAddListener, q as Separator, r as GuildDeleteListener, s as MessageReactionRemoveListener, t as discord_exports, v as RateLimitError, w as Command, z as Container } from "./discord-BXpHW-cu.mjs";
|
|
2
|
+
import { C as parseDiscordActivityCustomIdForInteraction, D as parseDiscordModalCustomIdForInteraction, E as parseDiscordModalCustomId, O as decodeCustomIdComponent, T as parseDiscordComponentCustomIdForInteraction, c as parseExecApprovalData, d as buildDiscordComponentMessage, k as encodeCustomIdComponent, o as parseDiscordQuestionData, w as parseDiscordComponentCustomId, y as buildDiscordActivityCustomId } from "./components-MqMWUWnE.mjs";
|
|
3
|
+
import { C as resolveTimestampMs, E as getDiscordEndpointRuntime, T as assertDiscordEndpointGatewayUrl, a as normalizeDiscordDisplaySlug, b as formatDiscordReactionEmoji, c as resolveDiscordChannelConfig, f as resolveDiscordGuildEntry, g as resolveDiscordOwnerAllowFrom, h as resolveDiscordOwnerAccess, i as normalizeDiscordAllowList, l as resolveDiscordChannelConfigWithFallback, m as resolveDiscordMemberAllowed, o as normalizeDiscordSlug, p as resolveDiscordMemberAccessState, r as isDiscordGroupAllowedByPolicy, s as resolveDiscordAllowListMatch, t as isDiscordThreadChannelType, u as resolveDiscordChannelPolicyCommandAuthorizer, v as resolveGroupDmAllow, x as formatDiscordUserTag, y as shouldEmitDiscordReactionNotification } from "./channel-type-DKnjV1XW.mjs";
|
|
4
|
+
import { c as resolveDiscordAccount, f as resolveDiscordAccountDmPolicy, h as resolveDiscordToken, l as resolveDiscordAccountAllowFrom, m as normalizeDiscordToken, o as mergeDiscordAccountConfig, p as resolveDiscordMaxLinesPerMessage } from "./accounts-CwJQoLjM.mjs";
|
|
5
|
+
import { a as registerDiscordComponentEntries, o as resolveDiscordComponentEntryWithPersistence, s as resolveDiscordModalEntryWithPersistence, t as editDiscordComponentMessage } from "./send.components-DWQjXhPV.mjs";
|
|
6
|
+
import { t as getDiscordRuntime } from "./runtime-DgnVQ7zW.mjs";
|
|
7
|
+
import { a as isDiscordRateLimitResponseBody, o as summarizeDiscordResponseBody } from "./api-CBK9zcq5.mjs";
|
|
8
|
+
import { o as chunkDiscordTextWithMode } from "./retry-DBfcEgmO.mjs";
|
|
9
|
+
import { B as validateDiscordProxyUrl, G as unregisterGateway, P as createDiscordRestClient, R as DISCORD_REST_TIMEOUT_MS, V as withValidatedDiscordProxy, W as registerGateway, b as canViewDiscordGuildChannel, w as hasAnyChannelPermissionDiscord } from "./send.shared-Zwx6BxQ5.mjs";
|
|
10
|
+
import { o as formatMention, t as sendMessageDiscord } from "./send.outbound-D0hQ7s50.mjs";
|
|
11
|
+
import { n as getDiscordActivitiesRuntime } from "./runtime-BVoa7hhx.mjs";
|
|
12
|
+
import { t as resolveDiscordCommandOwnerAllowFrom } from "./command-owners-D78sAoOz.mjs";
|
|
13
|
+
import { n as resolveDiscordChannelInfoSafe, o as resolveDiscordChannelTopicSafe, r as resolveDiscordChannelNameSafe } from "./channel-access-C12aDZ0p.mjs";
|
|
14
|
+
import { D as resolveDiscordMessageStickers, c as resolveDiscordVoiceAccess, d as resolveFetchedDiscordThreadLikeChannelContext, o as resolveDiscordVoiceEnabled, r as setDiscordTranscriptsVoiceManager, s as authorizeDiscordVoiceIngress, u as resolveDiscordThreadLikeChannelContext } from "./transcripts-source-CuWYgayu.mjs";
|
|
15
|
+
import { i as setPresence, t as clearPresences } from "./presence-cache-dYSHPWMx.mjs";
|
|
16
|
+
import { _ as readMessagesDiscord, s as sendVoiceMessageDiscord } from "./send-CKDczUNL.mjs";
|
|
17
|
+
import { c as raceWithTimeout, u as withAbortTimeout } from "./timeouts-D86uWLt_.mjs";
|
|
18
|
+
import { D as isDiscordExecApprovalClientEnabled, T as getDiscordExecApprovalApprovers, a as resolveDiscordComponentSpec, c as formatDiscordApprovalDisplayValue, d as resolveDiscordBoundConversationRoute, h as resolveDiscordConversationIdentity, l as buildDiscordConversationRouteContext, n as DISCORD_PRESENTATION_CAPABILITIES, p as resolveDiscordEffectiveRoute, r as buildDiscordPresentationPayload, s as DISCORD_APPROVAL_ALLOWED_MENTIONS } from "./outbound-session-route-CqWbuMOm.mjs";
|
|
19
|
+
import { n as discordIngressIdentity, t as selectDiscordLivePolicyConfig } from "./live-policy-config-eKQ-PLdy.mjs";
|
|
20
|
+
import { t as resolveDiscordChannelAllowlist } from "./resolve-channels-BbvsLQOZ.mjs";
|
|
21
|
+
import { t as resolveDiscordUserAllowlist } from "./resolve-users-ByFlR7LQ.mjs";
|
|
22
|
+
import { i as getThreadBindingManager, o as isThreadArchived, u as formatThreadBindingDurationLabel } from "./thread-bindings.manager-eexkKyrG.mjs";
|
|
23
|
+
import { a as probeDiscordApplicationId, r as parseApplicationIdFromToken } from "./probe-CupW4we4.mjs";
|
|
24
|
+
import { i as sanitizeRecentModels, n as normalizeModelRef, r as preferenceTimestampMs, t as buildPreferenceModelKey } from "./model-picker-preference-primitives-BHT1LkR_.mjs";
|
|
25
|
+
import { t as resolveDiscordSenderIdentity } from "./sender-identity-0Ymgvmaj.mjs";
|
|
26
|
+
import { n as hasDiscordApprovalControl, t as discordApprovalMessageUpdates } from "./approval-message-updates-BN7JtScm.mjs";
|
|
27
27
|
import { createRequire } from "node:module";
|
|
28
28
|
import { logDebug, logError } from "openclaw/plugin-sdk/logging-core";
|
|
29
29
|
import { ApplicationCommandOptionType, ButtonStyle, ChannelType, ComponentType, GatewayCloseCodes, GatewayCloseCodes as GatewayCloseCodes$1, GatewayDispatchEvents, GatewayIntentBits, GatewayOpcodes, PermissionFlagsBits } from "discord-api-types/v10";
|
|
@@ -33,15 +33,16 @@ import { createHash, randomUUID } from "node:crypto";
|
|
|
33
33
|
import { MAX_DATE_TIMESTAMP_MS, MAX_TIMER_TIMEOUT_MS, asDateTimestampMs, asSafeIntegerInRange, parseFiniteNumber, parseStrictInteger, parseStrictPositiveInteger, resolveDateTimestampMs, resolveTimestampMsToIsoString } from "openclaw/plugin-sdk/number-runtime";
|
|
34
34
|
import { expectDefined } from "openclaw/plugin-sdk/expect-runtime";
|
|
35
35
|
import { inspect } from "node:util";
|
|
36
|
+
import { createHttp1EnvHttpProxyAgent, createHttp1ProxyAgent, createNodeProxyAgent, resolveEnvHttpProxyAgentOptions, wrapFetchWithAbortSignal } from "openclaw/plugin-sdk/fetch-runtime";
|
|
36
37
|
import { readResponseWithLimit } from "openclaw/plugin-sdk/response-limit-runtime";
|
|
37
|
-
import {
|
|
38
|
-
import {
|
|
38
|
+
import { fetchWithSsrFGuard, formatErrorMessage, resolvePinnedHostnameWithPolicy } from "openclaw/plugin-sdk/ssrf-runtime";
|
|
39
|
+
import { PlatformMessageNotDispatchedError, formatErrorMessage as formatErrorMessage$1, toErrorObject } from "openclaw/plugin-sdk/error-runtime";
|
|
39
40
|
import { normalizeAccountId } from "openclaw/plugin-sdk/account-id";
|
|
40
41
|
import { resolveAgentRoute } from "openclaw/plugin-sdk/routing";
|
|
41
42
|
import { asFiniteNumber, asOptionalRecord, normalizeLowercaseStringOrEmpty, normalizeOptionalLowercaseString, normalizeOptionalString, normalizeStringEntries, parseFiniteNumber as parseFiniteNumber$1, parseStrictNonNegativeInteger as parseStrictNonNegativeInteger$1, summarizeStringEntries } from "openclaw/plugin-sdk/string-coerce-runtime";
|
|
42
43
|
import { createRuntimeConfigReader, getRuntimeConfig, getRuntimeConfigSnapshot } from "openclaw/plugin-sdk/runtime-config-snapshot";
|
|
43
|
-
import {
|
|
44
|
-
import {
|
|
44
|
+
import { renderPresentationForDelivery } from "openclaw/plugin-sdk/interactive-runtime";
|
|
45
|
+
import { hasOutboundReplyContent, resolveSendableOutboundReplyParts, resolveTextChunksWithFallback } from "openclaw/plugin-sdk/reply-payload";
|
|
45
46
|
import { createNonExitingRuntime, createSubsystemLogger, danger, formatDurationSeconds, isVerbose, logVerbose, shouldLogVerbose, sleepWithAbort, warn } from "openclaw/plugin-sdk/runtime-env";
|
|
46
47
|
import { sliceUtf16Safe, truncateUtf16Safe, withTimeout } from "openclaw/plugin-sdk/text-utility-runtime";
|
|
47
48
|
import { addAllowlistUserEntriesFromConfigEntry, buildAllowlistResolutionSummary, canonicalizeAllowlistWithResolvedIds, patchAllowlistUsersInConfigEntries, summarizeMapping } from "openclaw/plugin-sdk/allow-from";
|
|
@@ -54,8 +55,9 @@ import { loadWebMedia } from "openclaw/plugin-sdk/web-media";
|
|
|
54
55
|
import { createLazyRuntimeModule } from "openclaw/plugin-sdk/lazy-runtime";
|
|
55
56
|
import { buildCommandTextFromArgs, findCommandByNativeName, formatCommandArgMenuTitle, listChatCommands, listNativeCommandSpecsForConfig, listSkillCommandsForAgents, resolveCommandAuthorizedFromAuthorizers, resolveEffectiveAgentRuntime, resolveNativeCommandSessionTargets, resolveStoredModelOverride, serializeCommandArgs } from "openclaw/plugin-sdk/command-auth-native";
|
|
56
57
|
import { GROUP_POLICY_BLOCKED_LABEL, resolveDefaultGroupPolicy, resolveOpenProviderRuntimeGroupPolicy, warnMissingProviderGroupPolicyFallbackOnce } from "openclaw/plugin-sdk/runtime-group-policy";
|
|
58
|
+
import { pruneMapToMaxSize } from "openclaw/plugin-sdk/collection-runtime";
|
|
57
59
|
import { finalizeInboundContext } from "openclaw/plugin-sdk/reply-dispatch-runtime";
|
|
58
|
-
import { createChannelPartialDeliveryError, dispatchChannelInboundTurn, formatInboundEnvelope, hasVisibleInboundReplyDispatch, isChannelPartialDeliveryError, resolveEnvelopeFormatOptions, resolveInboundSupplementalSenderAllowed, runChannelInboundEvent } from "openclaw/plugin-sdk/channel-inbound";
|
|
60
|
+
import { createChannelPartialDeliveryError, createCommandTurnContext, dispatchChannelInboundTurn, formatInboundEnvelope, hasVisibleInboundReplyDispatch, isChannelPartialDeliveryError, resolveEnvelopeFormatOptions, resolveInboundSupplementalSenderAllowed, runChannelInboundEvent } from "openclaw/plugin-sdk/channel-inbound";
|
|
59
61
|
import path from "node:path";
|
|
60
62
|
import { resolvePinnedMainDmOwnerFromAllowlist as resolvePinnedMainDmOwnerFromAllowlist$1 } from "openclaw/plugin-sdk/security-runtime";
|
|
61
63
|
import { createChannelPairingChallengeIssuer } from "openclaw/plugin-sdk/channel-pairing";
|
|
@@ -78,6 +80,7 @@ import * as dns from "node:dns";
|
|
|
78
80
|
import { buildCommandTextFromArgs as buildCommandTextFromArgs$1, findCommandByNativeName as findCommandByNativeName$1, mergeNativeCommandSpecs, parseCommandArgs, resolveCommandArgChoices, resolveCommandArgMenu, serializeCommandArgs as serializeCommandArgs$1 } from "openclaw/plugin-sdk/native-command-registry";
|
|
79
81
|
import { PLUGIN_COMMAND_DISPATCH } from "openclaw/plugin-sdk/plugin-command-runtime";
|
|
80
82
|
import { resolveDirectStatusReplyForSession } from "openclaw/plugin-sdk/command-status-runtime";
|
|
83
|
+
import * as modelsProviderRuntime from "openclaw/plugin-sdk/models-provider-runtime";
|
|
81
84
|
import { normalizeProviderId } from "openclaw/plugin-sdk/provider-model-shared";
|
|
82
85
|
import { EventEmitter } from "node:events";
|
|
83
86
|
import { Agent as Agent$1 } from "node:https";
|
|
@@ -176,7 +179,7 @@ function resolveDiscordOnlinePresenceEvent(params) {
|
|
|
176
179
|
//#region extensions/discord/src/monitor/presence-cooldown-store.ts
|
|
177
180
|
const DISCORD_PRESENCE_COOLDOWN_MAX_ENTRIES = 25e3;
|
|
178
181
|
function openDiscordPresenceCooldownStore() {
|
|
179
|
-
return getDiscordRuntime().state.
|
|
182
|
+
return getDiscordRuntime().state.openKeyedStore({
|
|
180
183
|
namespace: "presence-greeting-cooldowns",
|
|
181
184
|
maxEntries: DISCORD_PRESENCE_COOLDOWN_MAX_ENTRIES,
|
|
182
185
|
overflowPolicy: "reject-new",
|
|
@@ -909,11 +912,14 @@ var DiscordPresenceListener = class extends PresenceUpdateListener {
|
|
|
909
912
|
this.pendingGuildSeeds = /* @__PURE__ */ new Map();
|
|
910
913
|
this.guildPresenceState = /* @__PURE__ */ new Map();
|
|
911
914
|
this.gatewayGeneration = 0;
|
|
915
|
+
this.stopped = false;
|
|
916
|
+
this.activeRuns = /* @__PURE__ */ new Set();
|
|
912
917
|
this.cooldownStore = params.cooldownStore ?? openDiscordPresenceCooldownStore();
|
|
913
918
|
this.presenceBaseline = params.presenceBaseline ?? new DiscordPresenceBaselineCache();
|
|
914
919
|
this.emissionGate = params.emissionGate ?? new DiscordPresenceEmissionGate();
|
|
915
920
|
}
|
|
916
921
|
async seedGuildSnapshot(data) {
|
|
922
|
+
if (this.stopped) return;
|
|
917
923
|
if (data.unavailable !== true && "presences" in data && Array.isArray(data.presences)) for (const presence of data.presences) {
|
|
918
924
|
const userId = presence.user?.id;
|
|
919
925
|
if (userId) setPresence(this.params.accountId, userId, {
|
|
@@ -970,23 +976,31 @@ var DiscordPresenceListener = class extends PresenceUpdateListener {
|
|
|
970
976
|
}
|
|
971
977
|
async handle(data, client) {
|
|
972
978
|
const userId = data.user?.id;
|
|
973
|
-
if (!userId) return;
|
|
979
|
+
if (!userId || this.stopped) return;
|
|
974
980
|
setPresence(this.params.accountId, userId, data);
|
|
975
981
|
const pendingSeed = this.pendingGuildSeeds.get(data.guild_id);
|
|
976
982
|
if (pendingSeed && !await pendingSeed) return;
|
|
983
|
+
if (this.stopped) return;
|
|
977
984
|
const presenceKey = `${this.params.accountId}:${data.guild_id}:${userId}`;
|
|
978
985
|
const gatewayGeneration = this.gatewayGeneration;
|
|
979
986
|
const guildGeneration = this.guildPresenceState.get(data.guild_id)?.generation ?? 0;
|
|
980
987
|
const run = (this.pendingByGuildUser.get(presenceKey) ?? Promise.resolve()).then(() => this.handleSerial(data, client, userId, presenceKey, gatewayGeneration, guildGeneration), () => this.handleSerial(data, client, userId, presenceKey, gatewayGeneration, guildGeneration));
|
|
981
988
|
this.pendingByGuildUser.set(presenceKey, run);
|
|
989
|
+
this.activeRuns.add(run);
|
|
982
990
|
try {
|
|
983
991
|
await run;
|
|
984
992
|
} catch (err) {
|
|
985
993
|
(this.params.logger ?? discordEventQueueLog).error(danger(`discord presence handler failed: ${String(err)}`));
|
|
986
994
|
} finally {
|
|
995
|
+
this.activeRuns.delete(run);
|
|
987
996
|
if (this.pendingByGuildUser.get(presenceKey) === run) this.pendingByGuildUser.delete(presenceKey);
|
|
988
997
|
}
|
|
989
998
|
}
|
|
999
|
+
async stop() {
|
|
1000
|
+
this.stopped = true;
|
|
1001
|
+
this.resetGatewaySession();
|
|
1002
|
+
await Promise.allSettled(this.activeRuns);
|
|
1003
|
+
}
|
|
990
1004
|
resetGatewaySession() {
|
|
991
1005
|
this.gatewayGeneration += 1;
|
|
992
1006
|
this.emissionGate.noteGatewaySessionReset(this.params.nowMs?.() ?? Date.now());
|
|
@@ -1021,6 +1035,8 @@ var DiscordPresenceListener = class extends PresenceUpdateListener {
|
|
|
1021
1035
|
})?.presenceEvents;
|
|
1022
1036
|
if (!config || config.enabled === false) return;
|
|
1023
1037
|
if (config.users !== void 0 && !config.users.includes(userId)) return;
|
|
1038
|
+
const lastEmittedAtMs = await this.cooldownStore.lookup(presenceKey);
|
|
1039
|
+
if (!this.isCurrentGeneration(data.guild_id, gatewayGeneration, guildGeneration) || policy?.isCurrent() === false) return;
|
|
1024
1040
|
const nowMs = this.params.nowMs?.() ?? Date.now();
|
|
1025
1041
|
const presenceScope = data.guild_id;
|
|
1026
1042
|
const presenceEvent = resolveDiscordOnlinePresenceEvent({
|
|
@@ -1029,7 +1045,7 @@ var DiscordPresenceListener = class extends PresenceUpdateListener {
|
|
|
1029
1045
|
availabilityKind: this.presenceBaseline.isOffline(presenceScope, presenceKey) ? "observed-offline" : this.guildPresenceState.get(data.guild_id)?.inferUnknownAsNewlyAvailable === true && !this.presenceBaseline.isOnline(presenceScope, presenceKey) ? "first-seen-after-snapshot" : null,
|
|
1030
1046
|
botUserId: this.params.botUserId,
|
|
1031
1047
|
nowMs,
|
|
1032
|
-
lastEmittedAtMs
|
|
1048
|
+
lastEmittedAtMs
|
|
1033
1049
|
});
|
|
1034
1050
|
if (!presenceEvent) {
|
|
1035
1051
|
if (isDiscordOfflineStatus(data.status)) this.recordPresenceBaseline(data.guild_id, presenceKey, "offline");
|
|
@@ -1090,7 +1106,8 @@ var DiscordPresenceListener = class extends PresenceUpdateListener {
|
|
|
1090
1106
|
}
|
|
1091
1107
|
});
|
|
1092
1108
|
try {
|
|
1093
|
-
cooldownReserved = this.cooldownStore.registerIfAbsent(presenceKey, nowMs, { ttlMs: DISCORD_PRESENCE_GREETING_COOLDOWN_MS });
|
|
1109
|
+
cooldownReserved = await this.cooldownStore.registerIfAbsent(presenceKey, nowMs, { ttlMs: DISCORD_PRESENCE_GREETING_COOLDOWN_MS });
|
|
1110
|
+
if (!this.isCurrentGeneration(data.guild_id, gatewayGeneration, guildGeneration) || policy?.isCurrent() === false) return;
|
|
1094
1111
|
if (!cooldownReserved) {
|
|
1095
1112
|
this.recordPresenceBaseline(data.guild_id, presenceKey, "online");
|
|
1096
1113
|
return;
|
|
@@ -1124,11 +1141,11 @@ var DiscordPresenceListener = class extends PresenceUpdateListener {
|
|
|
1124
1141
|
});
|
|
1125
1142
|
} finally {
|
|
1126
1143
|
if (!burstCommitted) this.emissionGate.releaseBurst(data.guild_id, burstReservation);
|
|
1127
|
-
if (cooldownReserved && !burstCommitted
|
|
1144
|
+
if (cooldownReserved && !burstCommitted) await this.cooldownStore.deleteIfEqual?.(presenceKey, nowMs);
|
|
1128
1145
|
}
|
|
1129
1146
|
}
|
|
1130
1147
|
isCurrentGeneration(guildId, gatewayGeneration, guildGeneration) {
|
|
1131
|
-
return gatewayGeneration === this.gatewayGeneration && guildGeneration === (this.guildPresenceState.get(guildId)?.generation ?? 0);
|
|
1148
|
+
return !this.stopped && gatewayGeneration === this.gatewayGeneration && guildGeneration === (this.guildPresenceState.get(guildId)?.generation ?? 0);
|
|
1132
1149
|
}
|
|
1133
1150
|
recordPresenceBaseline(guildId, key, status) {
|
|
1134
1151
|
const evictedGuildId = status === "offline" ? this.presenceBaseline.observeOffline(guildId, key) : this.presenceBaseline.observeOnline(guildId, key);
|
|
@@ -1164,30 +1181,49 @@ var DiscordPresenceReadyListener = class extends ReadyListener {
|
|
|
1164
1181
|
this.presenceListener.resetGatewaySession();
|
|
1165
1182
|
}
|
|
1166
1183
|
};
|
|
1184
|
+
const DISCORD_THREAD_REJOIN_CLAIM_MAX_ENTRIES = 1e4;
|
|
1167
1185
|
var DiscordThreadUpdateListener = class extends ThreadUpdateListener {
|
|
1168
1186
|
constructor(cfg, logger) {
|
|
1169
1187
|
super();
|
|
1170
1188
|
this.cfg = cfg;
|
|
1171
1189
|
this.logger = logger;
|
|
1190
|
+
this.rejoinClaims = /* @__PURE__ */ new Map();
|
|
1172
1191
|
}
|
|
1173
|
-
|
|
1192
|
+
resetGatewaySession() {
|
|
1193
|
+
this.rejoinClaims.clear();
|
|
1194
|
+
}
|
|
1195
|
+
async handle(data, client) {
|
|
1174
1196
|
await runDiscordListenerWithSlowLog({
|
|
1175
1197
|
logger: this.logger,
|
|
1176
1198
|
listener: this.constructor.name,
|
|
1177
1199
|
event: this.type,
|
|
1178
1200
|
run: async () => {
|
|
1179
|
-
if (!isThreadArchived(data)) return;
|
|
1180
1201
|
const threadId = "id" in data && typeof data.id === "string" ? data.id : void 0;
|
|
1181
1202
|
if (!threadId) return;
|
|
1182
1203
|
const logger = this.logger ?? discordEventQueueLog;
|
|
1183
|
-
|
|
1184
|
-
|
|
1185
|
-
|
|
1186
|
-
|
|
1187
|
-
|
|
1188
|
-
|
|
1189
|
-
count
|
|
1190
|
-
|
|
1204
|
+
if (isThreadArchived(data)) {
|
|
1205
|
+
this.rejoinClaims.delete(threadId);
|
|
1206
|
+
const count = await closeDiscordThreadSessions({
|
|
1207
|
+
cfg: this.cfg,
|
|
1208
|
+
threadId
|
|
1209
|
+
});
|
|
1210
|
+
if (count > 0) logger.info("Discord thread archived — reset sessions", {
|
|
1211
|
+
threadId,
|
|
1212
|
+
count
|
|
1213
|
+
});
|
|
1214
|
+
return;
|
|
1215
|
+
}
|
|
1216
|
+
if (this.rejoinClaims.has(threadId)) return;
|
|
1217
|
+
const claim = Symbol(threadId);
|
|
1218
|
+
this.rejoinClaims.set(threadId, claim);
|
|
1219
|
+
pruneMapToMaxSize(this.rejoinClaims, DISCORD_THREAD_REJOIN_CLAIM_MAX_ENTRIES);
|
|
1220
|
+
try {
|
|
1221
|
+
await client.rest.put(`/channels/${threadId}/thread-members/@me`);
|
|
1222
|
+
logger.info("Discord active thread — rejoined thread", { threadId });
|
|
1223
|
+
} catch (err) {
|
|
1224
|
+
if (this.rejoinClaims.get(threadId) === claim) this.rejoinClaims.delete(threadId);
|
|
1225
|
+
logger.warn(danger(`discord thread rejoin failed: ${String(err)}`), { threadId });
|
|
1226
|
+
}
|
|
1191
1227
|
},
|
|
1192
1228
|
onError: (err) => {
|
|
1193
1229
|
(this.logger ?? discordEventQueueLog).error(danger(`discord thread-update handler failed: ${String(err)}`));
|
|
@@ -1195,6 +1231,15 @@ var DiscordThreadUpdateListener = class extends ThreadUpdateListener {
|
|
|
1195
1231
|
});
|
|
1196
1232
|
}
|
|
1197
1233
|
};
|
|
1234
|
+
var DiscordThreadReadyListener = class extends ReadyListener {
|
|
1235
|
+
constructor(threadUpdateListener) {
|
|
1236
|
+
super();
|
|
1237
|
+
this.threadUpdateListener = threadUpdateListener;
|
|
1238
|
+
}
|
|
1239
|
+
handle() {
|
|
1240
|
+
this.threadUpdateListener.resetGatewaySession();
|
|
1241
|
+
}
|
|
1242
|
+
};
|
|
1198
1243
|
var DiscordThreadDeleteListener = class extends ThreadDeleteListener {
|
|
1199
1244
|
constructor(cfg, accountId, logger) {
|
|
1200
1245
|
super();
|
|
@@ -1438,7 +1483,7 @@ async function resolveGuildEntriesByChannelAllowlist(params) {
|
|
|
1438
1483
|
summarizeMapping("discord channels", mapping, unresolved, params.runtime);
|
|
1439
1484
|
return nextGuilds;
|
|
1440
1485
|
} catch (err) {
|
|
1441
|
-
params.runtime.log?.(`discord channel resolve failed; using config entries. ${formatErrorMessage
|
|
1486
|
+
params.runtime.log?.(`discord channel resolve failed; using config entries. ${formatErrorMessage(err)}`);
|
|
1442
1487
|
return params.guildEntries;
|
|
1443
1488
|
}
|
|
1444
1489
|
}
|
|
@@ -1462,7 +1507,7 @@ async function resolveAllowFromByUserAllowlist(params) {
|
|
|
1462
1507
|
summarizeMapping("discord users", mapping, unresolved, params.runtime);
|
|
1463
1508
|
return allowFrom;
|
|
1464
1509
|
} catch (err) {
|
|
1465
|
-
params.runtime.log?.(`discord user resolve failed; using config entries. ${formatErrorMessage
|
|
1510
|
+
params.runtime.log?.(`discord user resolve failed; using config entries. ${formatErrorMessage(err)}`);
|
|
1466
1511
|
return params.allowFrom;
|
|
1467
1512
|
}
|
|
1468
1513
|
}
|
|
@@ -1509,7 +1554,7 @@ async function resolveGuildEntriesByUserAllowlist(params) {
|
|
|
1509
1554
|
summarizeMapping("discord channel users", mapping, unresolved, params.runtime);
|
|
1510
1555
|
return nextGuilds;
|
|
1511
1556
|
} catch (err) {
|
|
1512
|
-
params.runtime.log?.(`discord channel user resolve failed; using config entries. ${formatErrorMessage
|
|
1557
|
+
params.runtime.log?.(`discord channel user resolve failed; using config entries. ${formatErrorMessage(err)}`);
|
|
1513
1558
|
return params.guildEntries;
|
|
1514
1559
|
}
|
|
1515
1560
|
}
|
|
@@ -1595,6 +1640,19 @@ function createDiscordDnsLookup() {
|
|
|
1595
1640
|
});
|
|
1596
1641
|
};
|
|
1597
1642
|
}
|
|
1643
|
+
function createDiscordEndpointDnsLookup(endpointHostname) {
|
|
1644
|
+
const normalizedEndpointHostname = normalizeHostname(endpointHostname);
|
|
1645
|
+
if (!normalizedEndpointHostname) throw new Error("Discord endpoint Gateway hostname is required");
|
|
1646
|
+
const policy = {
|
|
1647
|
+
allowedHostnames: [normalizedEndpointHostname],
|
|
1648
|
+
hostnameAllowlist: [normalizedEndpointHostname]
|
|
1649
|
+
};
|
|
1650
|
+
return (hostname, options, callback) => {
|
|
1651
|
+
resolvePinnedHostnameWithPolicy(hostname, { policy }).then((pinned) => pinned.lookup(pinned.hostname, options, callback), (error) => {
|
|
1652
|
+
callback(error instanceof Error ? error : new Error(String(error)), "", 4);
|
|
1653
|
+
});
|
|
1654
|
+
};
|
|
1655
|
+
}
|
|
1598
1656
|
//#endregion
|
|
1599
1657
|
//#region extensions/discord/src/monitor/rest-fetch.ts
|
|
1600
1658
|
const discordDnsLookup$1 = createDiscordDnsLookup();
|
|
@@ -1613,7 +1671,7 @@ function createEnvProxyDiscordRestDispatcher(runtime) {
|
|
|
1613
1671
|
connect: { lookup: discordDnsLookup$1 }
|
|
1614
1672
|
});
|
|
1615
1673
|
} catch (err) {
|
|
1616
|
-
runtime.error?.(danger(`discord: env proxy unavailable for REST fetch; using direct dispatcher: ${formatErrorMessage(err)}`));
|
|
1674
|
+
runtime.error?.(danger(`discord: env proxy unavailable for REST fetch; using direct dispatcher: ${formatErrorMessage$1(err)}`));
|
|
1617
1675
|
return;
|
|
1618
1676
|
}
|
|
1619
1677
|
}
|
|
@@ -1807,7 +1865,7 @@ function resolveDiscordInteractionMessageParts(payload) {
|
|
|
1807
1865
|
}
|
|
1808
1866
|
function hasRenderableReplyPayload(payload) {
|
|
1809
1867
|
const { components, embeds } = resolveDiscordInteractionMessageParts(payload);
|
|
1810
|
-
return
|
|
1868
|
+
return hasOutboundReplyContent(payload) || Boolean(components || embeds);
|
|
1811
1869
|
}
|
|
1812
1870
|
async function safeDiscordInteractionCall(label, fn) {
|
|
1813
1871
|
try {
|
|
@@ -1825,9 +1883,24 @@ async function settleDiscordInteractionWithoutVisibleReply(interaction) {
|
|
|
1825
1883
|
await safeDiscordInteractionCall("interaction delete deferred reply", () => interaction.deleteReply());
|
|
1826
1884
|
}
|
|
1827
1885
|
async function deliverDiscordInteractionReply(params) {
|
|
1828
|
-
const { interaction,
|
|
1886
|
+
const { interaction, textLimit, maxLinesPerMessage, preferFollowUp, chunkMode } = params;
|
|
1887
|
+
const nativeParts = resolveDiscordInteractionMessageParts(params.payload);
|
|
1888
|
+
const preserveNativeParts = resolveSendableOutboundReplyParts(params.payload).hasMedia || Boolean(nativeParts.components || nativeParts.embeds);
|
|
1889
|
+
const payload = await renderPresentationForDelivery({
|
|
1890
|
+
presentationCapabilities: DISCORD_PRESENTATION_CAPABILITIES,
|
|
1891
|
+
renderPresentation: (adapted) => preserveNativeParts ? null : buildDiscordPresentationPayload({
|
|
1892
|
+
payload: adapted,
|
|
1893
|
+
presentation: adapted.presentation
|
|
1894
|
+
})
|
|
1895
|
+
}, params.payload);
|
|
1896
|
+
const componentSpec = preserveNativeParts ? void 0 : await resolveDiscordComponentSpec(payload);
|
|
1897
|
+
let componentBuild = componentSpec ? buildDiscordComponentMessage({
|
|
1898
|
+
spec: componentSpec,
|
|
1899
|
+
...params.componentRoute
|
|
1900
|
+
}) : void 0;
|
|
1829
1901
|
const reply = resolveSendableOutboundReplyParts(payload);
|
|
1830
1902
|
let { components: firstMessageComponents, embeds: firstMessageEmbeds } = resolveDiscordInteractionMessageParts(payload);
|
|
1903
|
+
if (componentBuild) firstMessageComponents = componentBuild.components;
|
|
1831
1904
|
let payloadDelivered = false;
|
|
1832
1905
|
const sendMessage = async (content, files, components, embeds) => {
|
|
1833
1906
|
const hasV2 = hasDiscordV2Components(components);
|
|
@@ -1841,11 +1914,19 @@ async function deliverDiscordInteractionReply(params) {
|
|
|
1841
1914
|
let result;
|
|
1842
1915
|
try {
|
|
1843
1916
|
result = await safeDiscordInteractionCall("interaction send", async () => {
|
|
1844
|
-
|
|
1845
|
-
else await interaction.followUp(payloadLocal);
|
|
1917
|
+
const sent = !preferFollowUp && !payloadDelivered ? await interaction.reply(payloadLocal) : await interaction.followUp(payloadLocal);
|
|
1846
1918
|
payloadDelivered = true;
|
|
1847
1919
|
firstMessageComponents = void 0;
|
|
1848
1920
|
firstMessageEmbeds = void 0;
|
|
1921
|
+
if (componentBuild) {
|
|
1922
|
+
const messageId = sent && typeof sent === "object" && "id" in sent && typeof sent.id === "string" ? sent.id : void 0;
|
|
1923
|
+
await registerDiscordComponentEntries({
|
|
1924
|
+
entries: componentBuild.entries,
|
|
1925
|
+
modals: componentBuild.modals,
|
|
1926
|
+
messageId
|
|
1927
|
+
});
|
|
1928
|
+
componentBuild = void 0;
|
|
1929
|
+
}
|
|
1849
1930
|
});
|
|
1850
1931
|
} catch (error) {
|
|
1851
1932
|
if (!payloadDelivered) throw error;
|
|
@@ -1968,6 +2049,11 @@ async function dispatchDiscordNativeAgentReply(params) {
|
|
|
1968
2049
|
const payloadDelivered = await deliverDiscordInteractionReply({
|
|
1969
2050
|
interaction: params.interaction,
|
|
1970
2051
|
payload,
|
|
2052
|
+
componentRoute: {
|
|
2053
|
+
accountId: params.effectiveRoute.accountId,
|
|
2054
|
+
agentId: params.effectiveRoute.agentId,
|
|
2055
|
+
sessionKey: params.ctxPayload.CommandTargetSessionKey ?? params.effectiveRoute.sessionKey
|
|
2056
|
+
},
|
|
1971
2057
|
mediaLocalRoots: params.mediaLocalRoots,
|
|
1972
2058
|
textLimit: resolveTextChunkLimit(params.cfg, "discord", params.accountId, { fallbackLimit: 2e3 }),
|
|
1973
2059
|
maxLinesPerMessage: resolveDiscordMaxLinesPerMessage({
|
|
@@ -2343,7 +2429,7 @@ async function resolveDiscordNativeAutocompleteAuthorized(params) {
|
|
|
2343
2429
|
channel: interaction.channel,
|
|
2344
2430
|
client: interaction.client,
|
|
2345
2431
|
hasGuild: Boolean(interaction.guild),
|
|
2346
|
-
channelIdFallback: ""
|
|
2432
|
+
channelIdFallback: interaction.rawData.channel_id ?? ""
|
|
2347
2433
|
});
|
|
2348
2434
|
if (params.isPolicyCurrent?.() === false) return false;
|
|
2349
2435
|
const memberRoleIds = Array.isArray(interaction.rawData.member?.roles) ? interaction.rawData.member.roles.map((roleId) => roleId) : [];
|
|
@@ -2665,6 +2751,16 @@ async function recordDiscordModelPickerRecentModel(params) {
|
|
|
2665
2751
|
} catch {}
|
|
2666
2752
|
}
|
|
2667
2753
|
//#endregion
|
|
2754
|
+
//#region extensions/discord/src/monitor/model-picker.runtime.ts
|
|
2755
|
+
const hostSdk = modelsProviderRuntime;
|
|
2756
|
+
const MODEL_PICKER_CHANGED_MESSAGE = hostSdk.MODEL_PICKER_CHANGED_MESSAGE ?? "Available models changed. Open /models and choose again.";
|
|
2757
|
+
function supportsDiscordModelPickerRuntimeChoices() {
|
|
2758
|
+
return hostSdk.getModelsRuntimeChoices !== void 0;
|
|
2759
|
+
}
|
|
2760
|
+
function getDiscordModelPickerRuntimeChoices(...args) {
|
|
2761
|
+
return hostSdk.getModelsRuntimeChoices?.(...args);
|
|
2762
|
+
}
|
|
2763
|
+
//#endregion
|
|
2668
2764
|
//#region extensions/discord/src/monitor/model-picker.state.ts
|
|
2669
2765
|
const DISCORD_MODEL_PICKER_CUSTOM_ID_KEY = "mdlpk";
|
|
2670
2766
|
const DISCORD_CUSTOM_ID_MAX_CHARS = 100;
|
|
@@ -2701,10 +2797,13 @@ const PICKER_VIEWS = [
|
|
|
2701
2797
|
const DISCORD_MODEL_PICKER_BUCKET_THRESHOLD = DISCORD_COMPONENT_MAX_SELECT_OPTIONS;
|
|
2702
2798
|
/** Target items per alpha bucket. Discord caps selects at 25 options. */
|
|
2703
2799
|
const DISCORD_MODEL_PICKER_BUCKET_TARGET_SIZE = 20;
|
|
2704
|
-
const
|
|
2800
|
+
const DISCORD_MODEL_PICKER_TOKEN_PATTERN = /^[A-Za-z0-9_-]{8}$/u;
|
|
2705
2801
|
function createDiscordModelPickerModelToken(provider, model) {
|
|
2706
2802
|
return createHash("sha256").update(JSON.stringify([normalizeProviderId(provider), model]), "utf8").digest("base64url").slice(0, 8);
|
|
2707
2803
|
}
|
|
2804
|
+
function createDiscordModelPickerRuntimeToken(runtime) {
|
|
2805
|
+
return createHash("sha256").update(runtime, "utf8").digest("base64url").slice(0, 8);
|
|
2806
|
+
}
|
|
2708
2807
|
const loadModelsProviderRuntime = createLazyRuntimeModule(() => import("openclaw/plugin-sdk/models-provider-runtime"));
|
|
2709
2808
|
function isValidCommandContext(value) {
|
|
2710
2809
|
return COMMAND_CONTEXTS.includes(value);
|
|
@@ -2754,9 +2853,9 @@ function paginateItems(params) {
|
|
|
2754
2853
|
hasNext: page < totalPages
|
|
2755
2854
|
};
|
|
2756
2855
|
}
|
|
2757
|
-
async function loadDiscordModelPickerData(cfg, agentId) {
|
|
2856
|
+
async function loadDiscordModelPickerData(cfg, agentId, options) {
|
|
2758
2857
|
const { buildPreparedModelsProviderData } = await loadModelsProviderRuntime();
|
|
2759
|
-
return buildPreparedModelsProviderData(cfg, agentId);
|
|
2858
|
+
return buildPreparedModelsProviderData(cfg, agentId, options);
|
|
2760
2859
|
}
|
|
2761
2860
|
function buildDiscordModelPickerCustomId(params) {
|
|
2762
2861
|
const userId = params.userId.trim();
|
|
@@ -2767,7 +2866,7 @@ function buildDiscordModelPickerCustomId(params) {
|
|
|
2767
2866
|
const modelIndex = normalizeOptionalModelPickerIndex(params.modelIndex);
|
|
2768
2867
|
const recentSlot = normalizeOptionalModelPickerIndex(params.recentSlot);
|
|
2769
2868
|
const modelToken = params.modelToken?.trim();
|
|
2770
|
-
if (modelToken && !
|
|
2869
|
+
if (modelToken && !DISCORD_MODEL_PICKER_TOKEN_PATTERN.test(modelToken)) throw new Error("Discord model picker model token is invalid");
|
|
2771
2870
|
const parts = [
|
|
2772
2871
|
`${DISCORD_MODEL_PICKER_CUSTOM_ID_KEY}:c=${encodeCustomIdComponent(params.command)}`,
|
|
2773
2872
|
`a=${encodeCustomIdComponent(params.action)}`,
|
|
@@ -2778,6 +2877,9 @@ function buildDiscordModelPickerCustomId(params) {
|
|
|
2778
2877
|
if (normalizedProvider) parts.push(`p=${encodeCustomIdComponent(normalizedProvider)}`);
|
|
2779
2878
|
const runtime = params.runtime?.trim();
|
|
2780
2879
|
if (runtime) parts.push(`r=${encodeCustomIdComponent(runtime)}`);
|
|
2880
|
+
const runtimeToken = params.runtimeToken?.trim();
|
|
2881
|
+
if (runtimeToken && !DISCORD_MODEL_PICKER_TOKEN_PATTERN.test(runtimeToken)) throw new Error("Discord model picker runtime token is invalid");
|
|
2882
|
+
if (runtimeToken) parts.push(`rt=${runtimeToken}`);
|
|
2781
2883
|
const runtimeIndex = normalizeOptionalModelPickerIndex(params.runtimeIndex);
|
|
2782
2884
|
if (runtimeIndex) parts.push(`ri=${String(runtimeIndex)}`);
|
|
2783
2885
|
if (providerPage) parts.push(`pp=${String(providerPage)}`);
|
|
@@ -2790,6 +2892,13 @@ function buildDiscordModelPickerCustomId(params) {
|
|
|
2790
2892
|
if (providerBucket) parts.push(`pb=${encodeCustomIdComponent(providerBucket)}`);
|
|
2791
2893
|
const modelBucket = params.modelBucket?.trim().toLowerCase();
|
|
2792
2894
|
if (modelBucket) parts.push(`mb=${encodeCustomIdComponent(modelBucket)}`);
|
|
2895
|
+
if (parts.join(";").length > DISCORD_CUSTOM_ID_MAX_CHARS) {
|
|
2896
|
+
for (let index = parts.length - 1; index >= 0; index -= 1) if (parts[index] === "g=1" || parts[index] === "pp=1") parts.splice(index, 1);
|
|
2897
|
+
}
|
|
2898
|
+
if (modelToken && parts.join(";").length > DISCORD_CUSTOM_ID_MAX_CHARS) {
|
|
2899
|
+
const providerPart = parts.findIndex((part) => part.startsWith("p="));
|
|
2900
|
+
if (providerPart >= 0) parts.splice(providerPart, 1);
|
|
2901
|
+
}
|
|
2793
2902
|
const customId = parts.join(";");
|
|
2794
2903
|
if (customId.length > DISCORD_CUSTOM_ID_MAX_CHARS) throw new Error(`Discord model picker custom_id exceeds ${DISCORD_CUSTOM_ID_MAX_CHARS} chars (${customId.length})`);
|
|
2795
2904
|
return customId;
|
|
@@ -2803,11 +2912,18 @@ function parseDiscordModelPickerData(data) {
|
|
|
2803
2912
|
const providerRaw = decodeCustomIdComponent(coerceString(data.p));
|
|
2804
2913
|
const runtimeRaw = decodeCustomIdComponent(coerceString(data.r));
|
|
2805
2914
|
const runtimeIndex = parseStrictPositiveInteger(data.ri);
|
|
2915
|
+
const runtimeTokenRaw = coerceString(data.rt).trim();
|
|
2916
|
+
if (runtimeTokenRaw && !DISCORD_MODEL_PICKER_TOKEN_PATTERN.test(runtimeTokenRaw)) return null;
|
|
2917
|
+
if ([
|
|
2918
|
+
runtimeRaw.trim(),
|
|
2919
|
+
runtimeTokenRaw,
|
|
2920
|
+
runtimeIndex
|
|
2921
|
+
].filter(Boolean).length > 1) return null;
|
|
2806
2922
|
const page = parseRawPage(data.g ?? data.pg);
|
|
2807
2923
|
const providerPage = parseStrictPositiveInteger(data.pp);
|
|
2808
2924
|
const modelIndex = parseStrictPositiveInteger(data.mi);
|
|
2809
2925
|
const modelTokenRaw = coerceString(data.m).trim();
|
|
2810
|
-
const modelToken =
|
|
2926
|
+
const modelToken = DISCORD_MODEL_PICKER_TOKEN_PATTERN.test(modelTokenRaw) ? modelTokenRaw : void 0;
|
|
2811
2927
|
const recentSlot = parseStrictPositiveInteger(data.rs);
|
|
2812
2928
|
const providerBucketRaw = decodeCustomIdComponent(coerceString(data.pb)).trim().toLowerCase();
|
|
2813
2929
|
const modelBucketRaw = decodeCustomIdComponent(coerceString(data.mb)).trim().toLowerCase();
|
|
@@ -2821,6 +2937,7 @@ function parseDiscordModelPickerData(data) {
|
|
|
2821
2937
|
userId: trimmedUserId,
|
|
2822
2938
|
provider: providerRaw ? normalizeProviderId(providerRaw) : void 0,
|
|
2823
2939
|
runtime: runtimeRaw.trim() || void 0,
|
|
2940
|
+
...runtimeTokenRaw ? { runtimeToken: runtimeTokenRaw } : {},
|
|
2824
2941
|
...typeof runtimeIndex === "number" ? { runtimeIndex } : {},
|
|
2825
2942
|
page,
|
|
2826
2943
|
...typeof providerPage === "number" ? { providerPage } : {},
|
|
@@ -3063,7 +3180,7 @@ function buildBucketSelectRow(params) {
|
|
|
3063
3180
|
page: 1,
|
|
3064
3181
|
provider: params.provider,
|
|
3065
3182
|
runtime: params.runtime,
|
|
3066
|
-
|
|
3183
|
+
runtimeToken: params.runtimeToken,
|
|
3067
3184
|
providerPage: params.providerPage,
|
|
3068
3185
|
modelIndex: params.modelIndex
|
|
3069
3186
|
}),
|
|
@@ -3073,54 +3190,29 @@ function buildBucketSelectRow(params) {
|
|
|
3073
3190
|
return new Row([select]);
|
|
3074
3191
|
}
|
|
3075
3192
|
function getRuntimeChoices(params) {
|
|
3076
|
-
const
|
|
3077
|
-
|
|
3078
|
-
return [{
|
|
3079
|
-
id: "openclaw",
|
|
3080
|
-
label: "OpenClaw Default",
|
|
3081
|
-
description: "Use the built-in OpenClaw runtime."
|
|
3082
|
-
}];
|
|
3083
|
-
}
|
|
3084
|
-
function resolveSelectedRuntime(params) {
|
|
3085
|
-
const choices = getRuntimeChoices({
|
|
3086
|
-
data: params.data,
|
|
3087
|
-
provider: params.provider
|
|
3088
|
-
});
|
|
3089
|
-
const allowed = new Set(choices.map((choice) => choice.id));
|
|
3090
|
-
const pending = params.pendingRuntime?.trim();
|
|
3091
|
-
if (pending && allowed.has(pending)) return pending;
|
|
3092
|
-
const current = params.currentRuntime?.trim();
|
|
3093
|
-
if (current && allowed.has(current)) return current;
|
|
3094
|
-
return choices[0]?.id ?? "openclaw";
|
|
3193
|
+
const model = parseCurrentModelRef(params.modelRef);
|
|
3194
|
+
return getDiscordModelPickerRuntimeChoices(params.data, params.provider, model?.provider === normalizeProviderId(params.provider) ? model.model : void 0);
|
|
3095
3195
|
}
|
|
3096
3196
|
function resolveExplicitRuntimeState(params) {
|
|
3097
|
-
const
|
|
3098
|
-
|
|
3099
|
-
|
|
3100
|
-
|
|
3101
|
-
|
|
3197
|
+
const runtime = params.pendingRuntime?.trim() || params.currentRuntime?.trim();
|
|
3198
|
+
return runtime && runtime !== "auto" && runtime !== "default" ? runtime : void 0;
|
|
3199
|
+
}
|
|
3200
|
+
function resolveSelectedRuntime(params) {
|
|
3201
|
+
const choices = getRuntimeChoices(params);
|
|
3202
|
+
const explicit = resolveExplicitRuntimeState(params);
|
|
3203
|
+
return explicit ? choices?.find((choice) => choice.id === explicit)?.id : choices?.[0]?.id;
|
|
3102
3204
|
}
|
|
3103
3205
|
function getActiveBucketId(bucket) {
|
|
3104
3206
|
return bucket && bucket.id !== "all" ? bucket.id : void 0;
|
|
3105
3207
|
}
|
|
3106
3208
|
function resolveCompactRuntimeState(params) {
|
|
3107
|
-
|
|
3108
|
-
const
|
|
3109
|
-
|
|
3110
|
-
return stateRuntime ? { runtime: stateRuntime } : {};
|
|
3209
|
+
if (!supportsDiscordModelPickerRuntimeChoices()) return {};
|
|
3210
|
+
const runtime = resolveExplicitRuntimeState(params);
|
|
3211
|
+
return runtime ? { runtimeToken: createDiscordModelPickerRuntimeToken(runtime) } : {};
|
|
3111
3212
|
}
|
|
3112
3213
|
function buildRenderedShell(params) {
|
|
3113
|
-
if (params.layout === "classic") return {
|
|
3114
|
-
layout: "classic",
|
|
3115
|
-
content: [
|
|
3116
|
-
params.title,
|
|
3117
|
-
...params.detailLines,
|
|
3118
|
-
"",
|
|
3119
|
-
params.footer
|
|
3120
|
-
].filter(Boolean).join("\n"),
|
|
3121
|
-
components: params.rows
|
|
3122
|
-
};
|
|
3123
3214
|
const containerComponents = [new TextDisplay(`## ${params.title}`)];
|
|
3215
|
+
if (params.refreshWarning) containerComponents.push(new TextDisplay(params.refreshWarning));
|
|
3124
3216
|
if (params.detailLines.length > 0) containerComponents.push(new TextDisplay(params.detailLines.join("\n")));
|
|
3125
3217
|
containerComponents.push(new Separator({
|
|
3126
3218
|
divider: true,
|
|
@@ -3142,10 +3234,7 @@ function buildRenderedShell(params) {
|
|
|
3142
3234
|
}));
|
|
3143
3235
|
containerComponents.push(new TextDisplay(`-# ${params.footer}`));
|
|
3144
3236
|
}
|
|
3145
|
-
return {
|
|
3146
|
-
layout: "v2",
|
|
3147
|
-
components: [new Container(containerComponents)]
|
|
3148
|
-
};
|
|
3237
|
+
return { components: [new Container(containerComponents)] };
|
|
3149
3238
|
}
|
|
3150
3239
|
function buildProviderSelectRow(params) {
|
|
3151
3240
|
if (params.page.items.length === 0) return null;
|
|
@@ -3226,20 +3315,22 @@ function buildModelRows(params) {
|
|
|
3226
3315
|
})]));
|
|
3227
3316
|
const runtimeChoices = getRuntimeChoices({
|
|
3228
3317
|
data: params.data,
|
|
3229
|
-
provider: params.modelPage.provider
|
|
3318
|
+
provider: params.modelPage.provider,
|
|
3319
|
+
modelRef: params.pendingModel ?? params.currentModel
|
|
3230
3320
|
});
|
|
3321
|
+
const currentRuntime = parsedCurrentModel?.provider === params.modelPage.provider ? params.currentRuntime : void 0;
|
|
3231
3322
|
const selectedRuntime = resolveSelectedRuntime({
|
|
3232
3323
|
data: params.data,
|
|
3233
3324
|
provider: params.modelPage.provider,
|
|
3234
|
-
|
|
3325
|
+
modelRef: params.pendingModel ?? params.currentModel,
|
|
3326
|
+
currentRuntime,
|
|
3235
3327
|
pendingRuntime: params.pendingRuntime
|
|
3236
3328
|
});
|
|
3237
3329
|
const compactRuntime = resolveCompactRuntimeState({
|
|
3238
|
-
|
|
3239
|
-
currentRuntime: params.currentRuntime,
|
|
3330
|
+
currentRuntime,
|
|
3240
3331
|
pendingRuntime: params.pendingRuntime
|
|
3241
3332
|
});
|
|
3242
|
-
if (runtimeChoices.length > 1) rows.push(new Row([createModelSelect({
|
|
3333
|
+
if (runtimeChoices && (runtimeChoices.length > 1 || runtimeChoices.length === 1 && selectedRuntime === void 0)) rows.push(new Row([createModelSelect({
|
|
3243
3334
|
customId: buildDiscordModelPickerCustomId({
|
|
3244
3335
|
command: params.command,
|
|
3245
3336
|
action: "runtime",
|
|
@@ -3261,7 +3352,7 @@ function buildModelRows(params) {
|
|
|
3261
3352
|
if (choice.description) option.description = choice.description;
|
|
3262
3353
|
return option;
|
|
3263
3354
|
}),
|
|
3264
|
-
placeholder: "
|
|
3355
|
+
placeholder: "Choose how to run this model"
|
|
3265
3356
|
})]));
|
|
3266
3357
|
const selectedModelRef = parsedPendingModel ?? parsedCurrentModel;
|
|
3267
3358
|
const modelOptions = params.modelPage.items.map((model) => ({
|
|
@@ -3352,7 +3443,7 @@ function buildModelRows(params) {
|
|
|
3352
3443
|
buttonRowItems.push(createModelPickerButton({
|
|
3353
3444
|
label: "Submit",
|
|
3354
3445
|
style: ButtonStyle.Primary,
|
|
3355
|
-
disabled: !hasPendingSelection,
|
|
3446
|
+
disabled: !hasPendingSelection || supportsDiscordModelPickerRuntimeChoices() && selectedRuntime === void 0,
|
|
3356
3447
|
customId: buildDiscordModelPickerCustomId({
|
|
3357
3448
|
...modelActionState,
|
|
3358
3449
|
action: "submit",
|
|
@@ -3406,8 +3497,8 @@ function renderDiscordModelPickerProvidersView(params) {
|
|
|
3406
3497
|
const detailLines = [formatCurrentModelLine(params.currentModel), page.bucket && page.bucket.id !== "all" ? `Select a provider (${page.totalItems} in ${page.bucket.label}, ${totalProviders} total).` : `Select a provider (${page.totalItems} available).`];
|
|
3407
3498
|
const footer = page.totalPages > 1 ? `Showing page ${page.page}/${page.totalPages} · ${page.totalItems} providers total` : `All ${page.totalItems} providers shown`;
|
|
3408
3499
|
return buildRenderedShell({
|
|
3409
|
-
layout: params.layout ?? "v2",
|
|
3410
3500
|
title: "Model Picker",
|
|
3501
|
+
refreshWarning: params.data.refreshWarning,
|
|
3411
3502
|
detailLines,
|
|
3412
3503
|
rows,
|
|
3413
3504
|
footer
|
|
@@ -3433,8 +3524,8 @@ function renderDiscordModelPickerModelsView(params) {
|
|
|
3433
3524
|
})
|
|
3434
3525
|
})])];
|
|
3435
3526
|
return buildRenderedShell({
|
|
3436
|
-
layout: params.layout ?? "v2",
|
|
3437
3527
|
title: "Model Picker",
|
|
3528
|
+
refreshWarning: params.data.refreshWarning,
|
|
3438
3529
|
detailLines: [formatCurrentModelLine(params.currentModel), `Provider not found: ${normalizeProviderId(params.provider)}`],
|
|
3439
3530
|
rows,
|
|
3440
3531
|
footer: "Choose a different provider."
|
|
@@ -3454,12 +3545,7 @@ function renderDiscordModelPickerModelsView(params) {
|
|
|
3454
3545
|
quickModels: params.quickModels,
|
|
3455
3546
|
providerBucket: params.providerBucket
|
|
3456
3547
|
});
|
|
3457
|
-
const runtimeChoices = getRuntimeChoices({
|
|
3458
|
-
data: params.data,
|
|
3459
|
-
provider: modelPage.provider
|
|
3460
|
-
});
|
|
3461
3548
|
const pendingRuntime = params.pendingRuntime?.trim();
|
|
3462
|
-
const pendingRuntimeIndex = pendingRuntime ? runtimeChoices.findIndex((choice) => choice.id === pendingRuntime) : -1;
|
|
3463
3549
|
const rows = [];
|
|
3464
3550
|
const bucketRow = buildBucketSelectRow({
|
|
3465
3551
|
command: params.command,
|
|
@@ -3468,24 +3554,32 @@ function renderDiscordModelPickerModelsView(params) {
|
|
|
3468
3554
|
buckets: modelPage.buckets,
|
|
3469
3555
|
currentBucketId: modelPage.bucket?.id,
|
|
3470
3556
|
provider: modelPage.provider,
|
|
3471
|
-
|
|
3557
|
+
runtimeToken: pendingRuntime ? createDiscordModelPickerRuntimeToken(pendingRuntime) : void 0,
|
|
3472
3558
|
providerPage,
|
|
3473
3559
|
providerBucket: params.providerBucket
|
|
3474
3560
|
});
|
|
3475
3561
|
if (bucketRow) rows.push(bucketRow);
|
|
3476
3562
|
rows.push(...modelRows);
|
|
3477
3563
|
const defaultModel = `${params.data.resolvedDefault.provider}/${params.data.resolvedDefault.model}`;
|
|
3478
|
-
const
|
|
3564
|
+
const choices = getRuntimeChoices({
|
|
3479
3565
|
data: params.data,
|
|
3480
3566
|
provider: modelPage.provider,
|
|
3481
|
-
|
|
3567
|
+
modelRef: params.pendingModel ?? params.currentModel
|
|
3568
|
+
});
|
|
3569
|
+
const selectedRuntime = resolveSelectedRuntime({
|
|
3570
|
+
data: params.data,
|
|
3571
|
+
provider: modelPage.provider,
|
|
3572
|
+
modelRef: params.pendingModel ?? params.currentModel,
|
|
3573
|
+
currentRuntime: parseCurrentModelRef(params.currentModel)?.provider === modelPage.provider ? params.currentRuntime : void 0,
|
|
3482
3574
|
pendingRuntime: params.pendingRuntime
|
|
3483
|
-
})
|
|
3575
|
+
});
|
|
3576
|
+
const selectedRuntimeLabel = choices?.find((choice) => choice.id === selectedRuntime)?.label;
|
|
3577
|
+
const pendingLine = !params.pendingModel ? "Select a model, then press Submit." : !supportsDiscordModelPickerRuntimeChoices() ? `Selected: ${params.pendingModel} (press Submit)` : choices === void 0 ? "Could not confirm how to run this model. Open /models to try again." : choices.length === 0 ? "This model cannot run with your current connections. Choose another model." : selectedRuntimeLabel ? `Selected: ${params.pendingModel} · ${selectedRuntimeLabel} (press Submit)` : "Choose how to run this model, then press Submit.";
|
|
3484
3578
|
const detailLines = [formatCurrentModelLine(params.currentModel), `Default: ${defaultModel}`];
|
|
3485
3579
|
if (modelPage.totalPages > 1) detailLines.push(`${modelPage.provider}: page ${modelPage.page}/${modelPage.totalPages} · ${modelPage.totalItems} models`);
|
|
3486
3580
|
return buildRenderedShell({
|
|
3487
|
-
layout: params.layout ?? "v2",
|
|
3488
3581
|
title: "Model Picker",
|
|
3582
|
+
refreshWarning: params.data.refreshWarning,
|
|
3489
3583
|
detailLines,
|
|
3490
3584
|
preRowText: pendingLine,
|
|
3491
3585
|
rows,
|
|
@@ -3516,7 +3610,7 @@ function renderDiscordModelPickerRecentsView(params) {
|
|
|
3516
3610
|
modelToken: createModelRefToken(modelRef),
|
|
3517
3611
|
provider: params.provider,
|
|
3518
3612
|
runtime: params.runtime,
|
|
3519
|
-
|
|
3613
|
+
runtimeToken: params.runtimeToken,
|
|
3520
3614
|
page: params.page,
|
|
3521
3615
|
providerPage: params.providerPage,
|
|
3522
3616
|
userId: params.userId
|
|
@@ -3530,7 +3624,7 @@ function renderDiscordModelPickerRecentsView(params) {
|
|
|
3530
3624
|
view: "models",
|
|
3531
3625
|
provider: params.provider,
|
|
3532
3626
|
runtime: params.runtime,
|
|
3533
|
-
|
|
3627
|
+
runtimeToken: params.runtimeToken,
|
|
3534
3628
|
page: params.page,
|
|
3535
3629
|
providerPage: params.providerPage,
|
|
3536
3630
|
modelBucket: params.modelBucket,
|
|
@@ -3538,21 +3632,14 @@ function renderDiscordModelPickerRecentsView(params) {
|
|
|
3538
3632
|
})
|
|
3539
3633
|
})]);
|
|
3540
3634
|
return buildRenderedShell({
|
|
3541
|
-
layout: params.layout ?? "v2",
|
|
3542
3635
|
title: "Recents",
|
|
3636
|
+
refreshWarning: params.data.refreshWarning,
|
|
3543
3637
|
detailLines: ["Models you've previously selected appear here.", formatCurrentModelLine(params.currentModel)],
|
|
3544
3638
|
preRowText: "Tap a model to switch.",
|
|
3545
3639
|
rows,
|
|
3546
3640
|
trailingRows: [backRow]
|
|
3547
3641
|
});
|
|
3548
3642
|
}
|
|
3549
|
-
function toDiscordModelPickerMessagePayload(view) {
|
|
3550
|
-
if (view.layout === "classic") return {
|
|
3551
|
-
content: view.content,
|
|
3552
|
-
components: view.components
|
|
3553
|
-
};
|
|
3554
|
-
return { components: view.components };
|
|
3555
|
-
}
|
|
3556
3643
|
//#endregion
|
|
3557
3644
|
//#region extensions/discord/src/monitor/native-command-model-picker-apply.ts
|
|
3558
3645
|
function normalizeExpectedRuntime(value) {
|
|
@@ -3665,7 +3752,7 @@ async function resolveDiscordModelPickerRouteState(params) {
|
|
|
3665
3752
|
channel: interaction.channel,
|
|
3666
3753
|
client: interaction.client,
|
|
3667
3754
|
hasGuild: Boolean(interaction.guild),
|
|
3668
|
-
channelIdFallback: "unknown"
|
|
3755
|
+
channelIdFallback: interaction.rawData.channel_id ?? "unknown"
|
|
3669
3756
|
});
|
|
3670
3757
|
const memberRoleIds = Array.isArray(interaction.rawData.member?.roles) ? interaction.rawData.member.roles.map((roleId) => roleId) : [];
|
|
3671
3758
|
const threadBinding = isThreadChannel ? params.threadBindings.getByThreadId(rawChannelId) : void 0;
|
|
@@ -3780,7 +3867,12 @@ async function replyWithDiscordModelPickerProviders(params) {
|
|
|
3780
3867
|
accountId: params.accountId,
|
|
3781
3868
|
threadBindings: params.threadBindings
|
|
3782
3869
|
});
|
|
3783
|
-
const
|
|
3870
|
+
const sessionEntry = getSessionEntry({
|
|
3871
|
+
storePath: resolveStorePath(params.cfg.session?.store, { agentId: route.agentId }),
|
|
3872
|
+
sessionKey: route.sessionKey,
|
|
3873
|
+
readConsistency: "latest"
|
|
3874
|
+
});
|
|
3875
|
+
const data = await loadDiscordModelPickerData(params.cfg, route.agentId, { sessionEntry });
|
|
3784
3876
|
const currentModel = resolveDiscordModelPickerCurrentModel({
|
|
3785
3877
|
cfg: params.cfg,
|
|
3786
3878
|
route,
|
|
@@ -3810,7 +3902,7 @@ async function replyWithDiscordModelPickerProviders(params) {
|
|
|
3810
3902
|
const initialModelBucket = initialResolved.bucket;
|
|
3811
3903
|
const initialProviderLocation = findProviderBucketLocation(data, initialProvider);
|
|
3812
3904
|
const payload = {
|
|
3813
|
-
...
|
|
3905
|
+
...renderDiscordModelPickerModelsView({
|
|
3814
3906
|
command: params.command,
|
|
3815
3907
|
userId: params.userId,
|
|
3816
3908
|
data,
|
|
@@ -3822,7 +3914,7 @@ async function replyWithDiscordModelPickerProviders(params) {
|
|
|
3822
3914
|
currentModel,
|
|
3823
3915
|
currentRuntime,
|
|
3824
3916
|
quickModels
|
|
3825
|
-
})
|
|
3917
|
+
}),
|
|
3826
3918
|
ephemeral: true
|
|
3827
3919
|
};
|
|
3828
3920
|
await params.safeInteractionCall("model picker reply", async () => {
|
|
@@ -3854,9 +3946,10 @@ function resolveModelPickerSelectionValue(interaction) {
|
|
|
3854
3946
|
if (typeof first !== "string") return null;
|
|
3855
3947
|
return first.trim() || null;
|
|
3856
3948
|
}
|
|
3857
|
-
function
|
|
3858
|
-
if (!
|
|
3859
|
-
|
|
3949
|
+
function resolveRuntimeToken(choices, token) {
|
|
3950
|
+
if (!token) return;
|
|
3951
|
+
const matches = choices?.filter((choice) => createDiscordModelPickerRuntimeToken(choice.id) === token);
|
|
3952
|
+
return matches?.length === 1 ? matches[0]?.id : void 0;
|
|
3860
3953
|
}
|
|
3861
3954
|
function resolveModelPickerProvider(params) {
|
|
3862
3955
|
return params.parsedProvider ?? splitDiscordModelRef(params.currentModelRef ?? "")?.provider ?? params.data.resolvedDefault.provider;
|
|
@@ -3866,20 +3959,7 @@ function resolveSelectedBucket(interaction) {
|
|
|
3866
3959
|
return raw && raw !== "all" ? raw : void 0;
|
|
3867
3960
|
}
|
|
3868
3961
|
function resolvePendingRuntime(params) {
|
|
3869
|
-
return params.parsed.runtime ??
|
|
3870
|
-
data: params.data,
|
|
3871
|
-
provider: params.provider,
|
|
3872
|
-
runtimeIndex: params.parsed.runtimeIndex
|
|
3873
|
-
});
|
|
3874
|
-
}
|
|
3875
|
-
function resolveParsedRuntimeForSubmission(params) {
|
|
3876
|
-
if (params.parsed.runtime) return params.parsed.runtime;
|
|
3877
|
-
if (params.parsed.provider !== params.selectedProvider) return;
|
|
3878
|
-
return resolveModelPickerRuntimeByIndex({
|
|
3879
|
-
data: params.data,
|
|
3880
|
-
provider: params.selectedProvider,
|
|
3881
|
-
runtimeIndex: params.parsed.runtimeIndex
|
|
3882
|
-
});
|
|
3962
|
+
return params.parsed.runtime ?? resolveRuntimeToken(getDiscordModelPickerRuntimeChoices(params.data, params.provider), params.parsed.runtimeToken);
|
|
3883
3963
|
}
|
|
3884
3964
|
function resolveSubmittedModelRef(params) {
|
|
3885
3965
|
if (params.parsed.action === "reset") return `${params.data.resolvedDefault.provider}/${params.data.resolvedDefault.model}`;
|
|
@@ -3947,22 +4027,6 @@ function resolveDiscordModelPickerModelSelection(params) {
|
|
|
3947
4027
|
if (params.requireModelToken || !params.modelIndex || params.modelIndex < 1) return null;
|
|
3948
4028
|
return models[params.modelIndex - 1] ?? null;
|
|
3949
4029
|
}
|
|
3950
|
-
function resolveDiscordModelPickerRuntimeForProvider(params) {
|
|
3951
|
-
const runtime = normalizeOptionalString(params.runtime);
|
|
3952
|
-
if (!runtime) return;
|
|
3953
|
-
if (runtime === "auto" || runtime === "default") return params.allowResetRuntime ? runtime : void 0;
|
|
3954
|
-
const choices = params.data.runtimeChoicesByProvider?.get(params.provider);
|
|
3955
|
-
if (!choices?.length) return runtime === "openclaw" ? runtime : void 0;
|
|
3956
|
-
return choices.some((choice) => choice.id === runtime) ? runtime : void 0;
|
|
3957
|
-
}
|
|
3958
|
-
function resolveDiscordModelPickerSubmissionRuntime(params) {
|
|
3959
|
-
return resolveDiscordModelPickerRuntimeForProvider({
|
|
3960
|
-
data: params.data,
|
|
3961
|
-
provider: params.provider,
|
|
3962
|
-
runtime: params.parsedRuntime,
|
|
3963
|
-
allowResetRuntime: true
|
|
3964
|
-
});
|
|
3965
|
-
}
|
|
3966
4030
|
async function handleDiscordModelPickerInteraction(params) {
|
|
3967
4031
|
const { interaction, data, ctx } = params;
|
|
3968
4032
|
const parsed = parseDiscordModelPickerData(data);
|
|
@@ -3987,7 +4051,14 @@ async function handleDiscordModelPickerInteraction(params) {
|
|
|
3987
4051
|
accountId: ctx.accountId,
|
|
3988
4052
|
threadBindings: ctx.threadBindings
|
|
3989
4053
|
});
|
|
3990
|
-
const
|
|
4054
|
+
const sessionEntry = getSessionEntry({
|
|
4055
|
+
storePath: resolveStorePath(cfg.session?.store, { agentId: route.agentId }),
|
|
4056
|
+
sessionKey: route.sessionKey,
|
|
4057
|
+
readConsistency: "latest"
|
|
4058
|
+
});
|
|
4059
|
+
const pickerData = await loadDiscordModelPickerData(cfg, route.agentId, { sessionEntry });
|
|
4060
|
+
const tokenModel = parsed.modelToken ? resolveDiscordModelPickerModelRefByToken(pickerData, parsed.modelToken) : null;
|
|
4061
|
+
const parsedProvider = parsed.provider ?? splitDiscordModelRef(tokenModel ?? "")?.provider;
|
|
3991
4062
|
const currentModelRef = resolveDiscordModelPickerCurrentModel({
|
|
3992
4063
|
cfg,
|
|
3993
4064
|
route,
|
|
@@ -4024,39 +4095,60 @@ async function handleDiscordModelPickerInteraction(params) {
|
|
|
4024
4095
|
quickModels,
|
|
4025
4096
|
...state
|
|
4026
4097
|
});
|
|
4027
|
-
return await updatePicker(
|
|
4098
|
+
return await updatePicker(rendered);
|
|
4028
4099
|
};
|
|
4100
|
+
if (parsed.action !== "cancel" && pickerData.isCurrent?.() === false) {
|
|
4101
|
+
await showNotice("That model picker expired. Reopen /model to try again.");
|
|
4102
|
+
return;
|
|
4103
|
+
}
|
|
4104
|
+
if (parsed.runtimeIndex !== void 0 && parsed.action !== "cancel") {
|
|
4105
|
+
await showNotice("That runtime selection expired. Reopen /model and choose a runtime again.");
|
|
4106
|
+
return;
|
|
4107
|
+
}
|
|
4108
|
+
if (parsed.runtimeToken && ![
|
|
4109
|
+
"submit",
|
|
4110
|
+
"reset",
|
|
4111
|
+
"quick",
|
|
4112
|
+
"cancel"
|
|
4113
|
+
].includes(parsed.action) && parsedProvider && !resolvePendingRuntime({
|
|
4114
|
+
data: pickerData,
|
|
4115
|
+
provider: parsedProvider,
|
|
4116
|
+
parsed
|
|
4117
|
+
})) {
|
|
4118
|
+
await showNotice("That runtime selection expired. Reopen /model and choose a runtime again.");
|
|
4119
|
+
return;
|
|
4120
|
+
}
|
|
4029
4121
|
if (parsed.action === "recents") {
|
|
4030
|
-
await updatePicker(
|
|
4122
|
+
await updatePicker(renderDiscordModelPickerRecentsView({
|
|
4031
4123
|
command: parsed.command,
|
|
4032
4124
|
userId: parsed.userId,
|
|
4033
4125
|
data: pickerData,
|
|
4034
4126
|
quickModels,
|
|
4035
4127
|
currentModel: currentModelRef,
|
|
4036
4128
|
runtime: parsed.runtime,
|
|
4037
|
-
|
|
4129
|
+
runtimeToken: parsed.runtimeToken,
|
|
4038
4130
|
provider: parsed.provider,
|
|
4039
4131
|
page: parsed.page,
|
|
4040
4132
|
providerPage: parsed.providerPage,
|
|
4041
4133
|
modelBucket: parsed.modelBucket
|
|
4042
|
-
}))
|
|
4134
|
+
}));
|
|
4043
4135
|
return;
|
|
4044
4136
|
}
|
|
4045
4137
|
if (parsed.view === "providers" && (parsed.action === "back" || parsed.action === "nav" || parsed.action === "bucket")) {
|
|
4046
4138
|
const selectingBucket = parsed.action === "bucket";
|
|
4047
|
-
await updatePicker(
|
|
4139
|
+
await updatePicker(renderDiscordModelPickerProvidersView({
|
|
4048
4140
|
command: parsed.command,
|
|
4049
4141
|
userId: parsed.userId,
|
|
4050
4142
|
data: pickerData,
|
|
4051
4143
|
page: selectingBucket ? 1 : parsed.page,
|
|
4052
4144
|
providerBucket: selectingBucket ? resolveSelectedBucket(interaction) : parsed.providerBucket,
|
|
4053
4145
|
currentModel: currentModelRef
|
|
4054
|
-
}))
|
|
4146
|
+
}));
|
|
4055
4147
|
return;
|
|
4056
4148
|
}
|
|
4057
4149
|
if (parsed.action === "bucket" && parsed.view === "models") {
|
|
4058
4150
|
const provider = resolveModelPickerProvider({
|
|
4059
|
-
parsedProvider
|
|
4151
|
+
parsedProvider,
|
|
4060
4152
|
currentModelRef,
|
|
4061
4153
|
data: pickerData
|
|
4062
4154
|
});
|
|
@@ -4073,7 +4165,7 @@ async function handleDiscordModelPickerInteraction(params) {
|
|
|
4073
4165
|
}
|
|
4074
4166
|
if (parsed.action === "nav" && parsed.view === "models") {
|
|
4075
4167
|
const provider = resolveModelPickerProvider({
|
|
4076
|
-
parsedProvider
|
|
4168
|
+
parsedProvider,
|
|
4077
4169
|
currentModelRef,
|
|
4078
4170
|
data: pickerData
|
|
4079
4171
|
});
|
|
@@ -4085,7 +4177,7 @@ async function handleDiscordModelPickerInteraction(params) {
|
|
|
4085
4177
|
requireModelToken
|
|
4086
4178
|
});
|
|
4087
4179
|
if ((parsed.modelIndex || parsed.modelToken) && !pendingModel) {
|
|
4088
|
-
await showNotice(
|
|
4180
|
+
await showNotice(MODEL_PICKER_CHANGED_MESSAGE);
|
|
4089
4181
|
return;
|
|
4090
4182
|
}
|
|
4091
4183
|
const pendingModelIndex = pendingModel ? resolveDiscordModelPickerModelIndex({
|
|
@@ -4107,7 +4199,7 @@ async function handleDiscordModelPickerInteraction(params) {
|
|
|
4107
4199
|
}
|
|
4108
4200
|
if (parsed.action === "back" && parsed.view === "models") {
|
|
4109
4201
|
const provider = resolveModelPickerProvider({
|
|
4110
|
-
parsedProvider
|
|
4202
|
+
parsedProvider,
|
|
4111
4203
|
currentModelRef,
|
|
4112
4204
|
data: pickerData
|
|
4113
4205
|
});
|
|
@@ -4124,7 +4216,7 @@ async function handleDiscordModelPickerInteraction(params) {
|
|
|
4124
4216
|
if (parsed.action === "provider") {
|
|
4125
4217
|
const selectedProvider = resolveModelPickerSelectionValue(interaction) ?? parsed.provider;
|
|
4126
4218
|
if (!selectedProvider || !pickerData.byProvider.has(selectedProvider)) {
|
|
4127
|
-
await showNotice(
|
|
4219
|
+
await showNotice(MODEL_PICKER_CHANGED_MESSAGE);
|
|
4128
4220
|
return;
|
|
4129
4221
|
}
|
|
4130
4222
|
await updateModelsView(selectedProvider, {
|
|
@@ -4135,9 +4227,9 @@ async function handleDiscordModelPickerInteraction(params) {
|
|
|
4135
4227
|
}
|
|
4136
4228
|
if (parsed.action === "model") {
|
|
4137
4229
|
const selectedModel = resolveModelPickerSelectionValue(interaction);
|
|
4138
|
-
const provider =
|
|
4230
|
+
const provider = parsedProvider;
|
|
4139
4231
|
if (!provider || !selectedModel) {
|
|
4140
|
-
await showNotice(
|
|
4232
|
+
await showNotice(MODEL_PICKER_CHANGED_MESSAGE);
|
|
4141
4233
|
return;
|
|
4142
4234
|
}
|
|
4143
4235
|
const modelIndex = resolveDiscordModelPickerModelIndex({
|
|
@@ -4146,7 +4238,7 @@ async function handleDiscordModelPickerInteraction(params) {
|
|
|
4146
4238
|
model: selectedModel
|
|
4147
4239
|
});
|
|
4148
4240
|
if (!modelIndex) {
|
|
4149
|
-
await showNotice(
|
|
4241
|
+
await showNotice(MODEL_PICKER_CHANGED_MESSAGE);
|
|
4150
4242
|
return;
|
|
4151
4243
|
}
|
|
4152
4244
|
const modelRef = `${provider}/${selectedModel}`;
|
|
@@ -4163,10 +4255,10 @@ async function handleDiscordModelPickerInteraction(params) {
|
|
|
4163
4255
|
return;
|
|
4164
4256
|
}
|
|
4165
4257
|
if (parsed.action === "runtime") {
|
|
4166
|
-
const selectedRuntime = resolveModelPickerSelectionValue(interaction) ?? parsed.runtime
|
|
4167
|
-
const provider =
|
|
4258
|
+
const selectedRuntime = resolveModelPickerSelectionValue(interaction) ?? parsed.runtime;
|
|
4259
|
+
const provider = parsedProvider;
|
|
4168
4260
|
if (!provider || !pickerData.byProvider.has(provider)) {
|
|
4169
|
-
await showNotice(
|
|
4261
|
+
await showNotice(MODEL_PICKER_CHANGED_MESSAGE);
|
|
4170
4262
|
return;
|
|
4171
4263
|
}
|
|
4172
4264
|
const selectedModel = resolveDiscordModelPickerModelSelection({
|
|
@@ -4177,7 +4269,13 @@ async function handleDiscordModelPickerInteraction(params) {
|
|
|
4177
4269
|
requireModelToken
|
|
4178
4270
|
});
|
|
4179
4271
|
if ((parsed.modelIndex || parsed.modelToken) && !selectedModel) {
|
|
4180
|
-
await showNotice(
|
|
4272
|
+
await showNotice(MODEL_PICKER_CHANGED_MESSAGE);
|
|
4273
|
+
return;
|
|
4274
|
+
}
|
|
4275
|
+
const currentModel = splitDiscordModelRef(currentModelRef ?? "");
|
|
4276
|
+
const choices = getDiscordModelPickerRuntimeChoices(pickerData, provider, selectedModel ?? (currentModel?.provider === provider ? currentModel.model : void 0));
|
|
4277
|
+
if (!selectedRuntime || !choices?.some((choice) => choice.id === selectedRuntime)) {
|
|
4278
|
+
await showNotice("That runtime is not available for this model. Choose a runtime again.");
|
|
4181
4279
|
return;
|
|
4182
4280
|
}
|
|
4183
4281
|
const pendingModel = selectedModel ? `${provider}/${selectedModel}` : void 0;
|
|
@@ -4204,19 +4302,50 @@ async function handleDiscordModelPickerInteraction(params) {
|
|
|
4204
4302
|
});
|
|
4205
4303
|
const parsedModelRef = modelRef ? splitDiscordModelRef(modelRef) : null;
|
|
4206
4304
|
if (!parsedModelRef || !pickerData.byProvider.get(parsedModelRef.provider)?.has(parsedModelRef.model)) {
|
|
4207
|
-
await showNotice(
|
|
4305
|
+
await showNotice(MODEL_PICKER_CHANGED_MESSAGE);
|
|
4208
4306
|
return;
|
|
4209
4307
|
}
|
|
4210
4308
|
const resolvedModelRef = `${parsedModelRef.provider}/${parsedModelRef.model}`;
|
|
4211
|
-
const
|
|
4212
|
-
|
|
4213
|
-
|
|
4214
|
-
|
|
4215
|
-
|
|
4216
|
-
|
|
4217
|
-
|
|
4218
|
-
})
|
|
4219
|
-
|
|
4309
|
+
const choices = getDiscordModelPickerRuntimeChoices(pickerData, parsedModelRef.provider, parsedModelRef.model);
|
|
4310
|
+
const modelOnlyHost = !supportsDiscordModelPickerRuntimeChoices();
|
|
4311
|
+
const supportsModelOnlySelection = () => {
|
|
4312
|
+
const currentEntry = getSessionEntry({
|
|
4313
|
+
storePath: resolveStorePath(cfg.session?.store, { agentId: route.agentId }),
|
|
4314
|
+
sessionKey: route.sessionKey,
|
|
4315
|
+
readConsistency: "latest"
|
|
4316
|
+
});
|
|
4317
|
+
const override = currentEntry?.agentRuntimeOverride?.trim();
|
|
4318
|
+
if (override && ![
|
|
4319
|
+
"auto",
|
|
4320
|
+
"default",
|
|
4321
|
+
"openclaw"
|
|
4322
|
+
].includes(override)) return false;
|
|
4323
|
+
const model = pickerData.modelCatalog?.find((entry) => entry.provider === parsedModelRef.provider && entry.id === parsedModelRef.model);
|
|
4324
|
+
return resolveEffectiveAgentRuntime({
|
|
4325
|
+
cfg,
|
|
4326
|
+
provider: parsedModelRef.provider,
|
|
4327
|
+
modelId: parsedModelRef.model,
|
|
4328
|
+
modelApi: model?.api,
|
|
4329
|
+
modelBaseUrl: model?.baseUrl,
|
|
4330
|
+
agentId: route.agentId,
|
|
4331
|
+
sessionKey: route.sessionKey,
|
|
4332
|
+
sessionEntry: currentEntry
|
|
4333
|
+
}) === "openclaw";
|
|
4334
|
+
};
|
|
4335
|
+
const legacyRuntimeNotice = "This OpenClaw version supports model-only selection here. Update OpenClaw to change runtimes in the picker.";
|
|
4336
|
+
if (modelOnlyHost && (parsed.runtime || parsed.runtimeToken || !supportsModelOnlySelection())) {
|
|
4337
|
+
await showNotice(legacyRuntimeNotice);
|
|
4338
|
+
return;
|
|
4339
|
+
}
|
|
4340
|
+
if (!modelOnlyHost && choices === void 0) {
|
|
4341
|
+
await showNotice("Runtime availability is not confirmed. Reopen /model to try again.");
|
|
4342
|
+
return;
|
|
4343
|
+
}
|
|
4344
|
+
const selectedRuntime = normalizeOptionalString(parsed.runtime) ?? resolveRuntimeToken(choices, parsed.runtimeToken);
|
|
4345
|
+
if (choices?.length === 0 || parsed.runtimeToken && selectedRuntime === void 0 || selectedRuntime && selectedRuntime !== "auto" && selectedRuntime !== "default" && !choices?.some((choice) => choice.id === selectedRuntime)) {
|
|
4346
|
+
await showNotice("That runtime is not available for this model. Reopen /model and choose again.");
|
|
4347
|
+
return;
|
|
4348
|
+
}
|
|
4220
4349
|
const selectionCommand = buildDiscordModelPickerSelectionCommand({
|
|
4221
4350
|
modelRef: resolvedModelRef,
|
|
4222
4351
|
runtime: selectedRuntime
|
|
@@ -4226,6 +4355,14 @@ async function handleDiscordModelPickerInteraction(params) {
|
|
|
4226
4355
|
return;
|
|
4227
4356
|
}
|
|
4228
4357
|
if (await showNotice(`Applying model change to ${resolvedModelRef}...`) === null) return;
|
|
4358
|
+
if (pickerData.isCurrent?.() === false) {
|
|
4359
|
+
await showNotice("That model picker expired. Reopen /model to try again.");
|
|
4360
|
+
return;
|
|
4361
|
+
}
|
|
4362
|
+
if (modelOnlyHost && !supportsModelOnlySelection()) {
|
|
4363
|
+
await showNotice(legacyRuntimeNotice);
|
|
4364
|
+
return;
|
|
4365
|
+
}
|
|
4229
4366
|
const applyResult = await applyDiscordModelPickerSelection({
|
|
4230
4367
|
interaction,
|
|
4231
4368
|
selectionCommand,
|
|
@@ -4394,22 +4531,13 @@ function buildDiscordCommandOptions(params) {
|
|
|
4394
4531
|
if (!args || args.length === 0) return;
|
|
4395
4532
|
return args.map((arg) => {
|
|
4396
4533
|
const required = arg.required ?? false;
|
|
4397
|
-
if (arg.type === "number") return {
|
|
4398
|
-
name: arg.name,
|
|
4399
|
-
description: truncateDiscordCommandDescription({
|
|
4400
|
-
value: arg.description,
|
|
4401
|
-
label: `command:${commandLabel} arg:${arg.name}`
|
|
4402
|
-
}),
|
|
4403
|
-
type: ApplicationCommandOptionType.Number,
|
|
4404
|
-
required
|
|
4405
|
-
};
|
|
4406
|
-
if (arg.type === "boolean") return {
|
|
4534
|
+
if (arg.type === "number" || arg.type === "boolean") return {
|
|
4407
4535
|
name: arg.name,
|
|
4408
4536
|
description: truncateDiscordCommandDescription({
|
|
4409
4537
|
value: arg.description,
|
|
4410
4538
|
label: `command:${commandLabel} arg:${arg.name}`
|
|
4411
4539
|
}),
|
|
4412
|
-
type: ApplicationCommandOptionType.Boolean,
|
|
4540
|
+
type: arg.type === "number" ? ApplicationCommandOptionType.Number : ApplicationCommandOptionType.Boolean,
|
|
4413
4541
|
required
|
|
4414
4542
|
};
|
|
4415
4543
|
const resolvedChoices = resolveCommandArgChoices({
|
|
@@ -4440,7 +4568,7 @@ function buildDiscordCommandOptions(params) {
|
|
|
4440
4568
|
provider: context?.provider,
|
|
4441
4569
|
model: context?.model,
|
|
4442
4570
|
agentRuntime: context?.agentRuntime,
|
|
4443
|
-
|
|
4571
|
+
catalog: choiceCatalog
|
|
4444
4572
|
});
|
|
4445
4573
|
const filtered = focusValue ? choices.filter((choice) => normalizeLowercaseStringOrEmpty(choice.label).includes(focusValue)) : choices;
|
|
4446
4574
|
await interaction.respond(filtered.slice(0, 25).map((choice) => ({
|
|
@@ -4591,7 +4719,7 @@ async function dispatchDiscordCommandInteraction(params) {
|
|
|
4591
4719
|
channel,
|
|
4592
4720
|
client: interaction.client,
|
|
4593
4721
|
hasGuild: Boolean(interaction.guild),
|
|
4594
|
-
channelIdFallback: ""
|
|
4722
|
+
channelIdFallback: interaction.rawData.channel_id ?? ""
|
|
4595
4723
|
});
|
|
4596
4724
|
if (policy?.isCurrent() === false) {
|
|
4597
4725
|
await respond("Access policy changed. Try this interaction again.", { ephemeral: true });
|
|
@@ -4806,7 +4934,7 @@ async function dispatchDiscordCommandInteraction(params) {
|
|
|
4806
4934
|
provider: menuModelContext?.provider,
|
|
4807
4935
|
model: menuModelContext?.model,
|
|
4808
4936
|
agentRuntime: menuModelContext?.agentRuntime,
|
|
4809
|
-
|
|
4937
|
+
catalog: menuModelCatalog
|
|
4810
4938
|
});
|
|
4811
4939
|
if (menu) {
|
|
4812
4940
|
const menuPayload = buildDiscordCommandArgMenu({
|
|
@@ -5975,7 +6103,7 @@ function parseDiscordGatewayInfoBody(body) {
|
|
|
5975
6103
|
async function fetchDiscordGatewayInfo(params) {
|
|
5976
6104
|
let response;
|
|
5977
6105
|
try {
|
|
5978
|
-
response = await params.fetchImpl(DISCORD_GATEWAY_BOT_URL, {
|
|
6106
|
+
response = await params.fetchImpl(params.gatewayBotUrl ?? DISCORD_GATEWAY_BOT_URL, {
|
|
5979
6107
|
...params.fetchInit,
|
|
5980
6108
|
headers: {
|
|
5981
6109
|
...params.fetchInit?.headers,
|
|
@@ -5984,7 +6112,7 @@ async function fetchDiscordGatewayInfo(params) {
|
|
|
5984
6112
|
});
|
|
5985
6113
|
} catch (error) {
|
|
5986
6114
|
throw createGatewayMetadataError({
|
|
5987
|
-
detail: formatErrorMessage(error),
|
|
6115
|
+
detail: formatErrorMessage$1(error),
|
|
5988
6116
|
transient: true,
|
|
5989
6117
|
cause: error
|
|
5990
6118
|
});
|
|
@@ -5994,7 +6122,7 @@ async function fetchDiscordGatewayInfo(params) {
|
|
|
5994
6122
|
body = await response.text();
|
|
5995
6123
|
} catch (error) {
|
|
5996
6124
|
throw createGatewayMetadataError({
|
|
5997
|
-
detail: formatErrorMessage(error),
|
|
6125
|
+
detail: formatErrorMessage$1(error),
|
|
5998
6126
|
transient: true,
|
|
5999
6127
|
cause: error
|
|
6000
6128
|
});
|
|
@@ -6009,7 +6137,7 @@ async function fetchDiscordGatewayInfo(params) {
|
|
|
6009
6137
|
return parseDiscordGatewayInfoBody(body);
|
|
6010
6138
|
} catch (error) {
|
|
6011
6139
|
throw createGatewayMetadataError({
|
|
6012
|
-
detail: `Discord API /gateway/bot returned invalid metadata: ${formatErrorMessage(error)} (${summary})`,
|
|
6140
|
+
detail: `Discord API /gateway/bot returned invalid metadata: ${formatErrorMessage$1(error)} (${summary})`,
|
|
6013
6141
|
transient,
|
|
6014
6142
|
cause: error
|
|
6015
6143
|
});
|
|
@@ -6026,6 +6154,7 @@ async function fetchDiscordGatewayInfoWithTimeout(params) {
|
|
|
6026
6154
|
}),
|
|
6027
6155
|
run: async (signal) => await fetchDiscordGatewayInfo({
|
|
6028
6156
|
token: params.token,
|
|
6157
|
+
gatewayBotUrl: params.gatewayBotUrl,
|
|
6029
6158
|
fetchImpl: params.fetchImpl,
|
|
6030
6159
|
fetchInit: {
|
|
6031
6160
|
...params.fetchInit,
|
|
@@ -6036,7 +6165,7 @@ async function fetchDiscordGatewayInfoWithTimeout(params) {
|
|
|
6036
6165
|
}
|
|
6037
6166
|
function resolveGatewayInfoWithFallback(params) {
|
|
6038
6167
|
if (!isTransientGatewayMetadataError(params.error)) throw params.error;
|
|
6039
|
-
const message = formatErrorMessage(params.error);
|
|
6168
|
+
const message = formatErrorMessage$1(params.error);
|
|
6040
6169
|
const now = Date.now();
|
|
6041
6170
|
if (params.runtime) {
|
|
6042
6171
|
const previous = gatewayMetadataFallbackLogLastAt.get(params.runtime);
|
|
@@ -6179,16 +6308,20 @@ function createGatewayPlugin(params) {
|
|
|
6179
6308
|
if (!this.gatewayInfo || this.gatewayInfoUsedFallback) {
|
|
6180
6309
|
const resolved = await fetchDiscordGatewayInfoWithTimeout({
|
|
6181
6310
|
token: client.options.token,
|
|
6311
|
+
...params.endpoint ? { gatewayBotUrl: params.endpoint.gatewayBotUrl } : {},
|
|
6182
6312
|
fetchImpl: params.fetchImpl,
|
|
6183
6313
|
fetchInit: params.fetchInit,
|
|
6184
6314
|
timeoutMs: params.gatewayInfoTimeoutMs
|
|
6185
6315
|
}).then((info) => ({
|
|
6186
6316
|
info,
|
|
6187
6317
|
usedFallback: false
|
|
6188
|
-
})).catch((error) =>
|
|
6189
|
-
|
|
6190
|
-
|
|
6191
|
-
|
|
6318
|
+
})).catch((error) => {
|
|
6319
|
+
if (params.endpoint) throw error;
|
|
6320
|
+
return resolveGatewayInfoWithFallback({
|
|
6321
|
+
runtime: params.runtime,
|
|
6322
|
+
error
|
|
6323
|
+
});
|
|
6324
|
+
});
|
|
6192
6325
|
this.gatewayInfo = resolved.info;
|
|
6193
6326
|
this.gatewayInfoUsedFallback = resolved.usedFallback;
|
|
6194
6327
|
}
|
|
@@ -6201,6 +6334,7 @@ function createGatewayPlugin(params) {
|
|
|
6201
6334
|
}
|
|
6202
6335
|
createWebSocket(url) {
|
|
6203
6336
|
if (!url) throw new Error("Gateway URL is required");
|
|
6337
|
+
assertDiscordEndpointGatewayUrl(url, params.endpoint?.gatewayOrigin);
|
|
6204
6338
|
const wsFlowId = randomUUID();
|
|
6205
6339
|
const socket = new ((params.testing?.webSocketCtor) ?? WebSocket)(url, {
|
|
6206
6340
|
...DISCORD_GATEWAY_WS_CLIENT_OPTIONS,
|
|
@@ -6274,13 +6408,21 @@ function createGatewayPlugin(params) {
|
|
|
6274
6408
|
}
|
|
6275
6409
|
return new OpenClawGatewayPlugin();
|
|
6276
6410
|
}
|
|
6277
|
-
function createDiscordGatewayMetadataFetch(debugCaptureEnabled,
|
|
6411
|
+
function createDiscordGatewayMetadataFetch(debugCaptureEnabled, transport) {
|
|
6412
|
+
const endpoint = transport?.endpoint;
|
|
6413
|
+
if (endpoint) return (input, init) => {
|
|
6414
|
+
const signal = init?.signal instanceof AbortSignal ? init.signal : void 0;
|
|
6415
|
+
return endpoint.fetch(input, {
|
|
6416
|
+
...init?.headers ? { headers: init.headers } : {},
|
|
6417
|
+
...signal ? { signal } : {}
|
|
6418
|
+
});
|
|
6419
|
+
};
|
|
6278
6420
|
return (input, init) => fetchDiscordGatewayMetadataGuarded(input, init, {
|
|
6279
6421
|
...debugCaptureEnabled ? {} : { capture: {
|
|
6280
6422
|
flowId: randomUUID(),
|
|
6281
6423
|
meta: { subsystem: "discord-gateway-metadata" }
|
|
6282
6424
|
} },
|
|
6283
|
-
...proxyUrl ? { proxyUrl } : {}
|
|
6425
|
+
...transport?.proxyUrl ? { proxyUrl: transport.proxyUrl } : {}
|
|
6284
6426
|
});
|
|
6285
6427
|
}
|
|
6286
6428
|
function waitForDiscordGatewayPluginRegistration(plugin) {
|
|
@@ -6295,16 +6437,23 @@ function createDiscordGatewayPlugin(params) {
|
|
|
6295
6437
|
const proxy = resolveEffectiveDebugProxyUrl(params.discordConfig?.proxy);
|
|
6296
6438
|
const debugProxySettings = resolveDebugProxySettings();
|
|
6297
6439
|
const gatewayInfoTimeoutMs = resolveDiscordGatewayInfoTimeoutMs({ env: process.env });
|
|
6298
|
-
|
|
6299
|
-
|
|
6300
|
-
|
|
6440
|
+
const endpointRuntime = getDiscordEndpointRuntime();
|
|
6441
|
+
const endpoint = endpointRuntime ? {
|
|
6442
|
+
gatewayBotUrl: endpointRuntime.descriptor.gatewayBotUrl,
|
|
6443
|
+
gatewayOrigin: endpointRuntime.descriptor.gatewayOrigin,
|
|
6444
|
+
fetch: endpointRuntime.fetch
|
|
6445
|
+
} : void 0;
|
|
6446
|
+
const endpointGatewayUrl = endpoint ? new URL(endpoint.gatewayOrigin) : void 0;
|
|
6447
|
+
let fetchImpl = createDiscordGatewayMetadataFetch(debugProxySettings.enabled, endpoint ? { endpoint } : void 0);
|
|
6448
|
+
let wsAgent = endpointGatewayUrl?.protocol === "ws:" ? void 0 : new Agent$1({ lookup: endpointGatewayUrl ? createDiscordEndpointDnsLookup(endpointGatewayUrl.hostname) : discordDnsLookup });
|
|
6449
|
+
if (proxy && !endpoint) try {
|
|
6301
6450
|
validateDiscordProxyUrl(proxy);
|
|
6302
6451
|
wsAgent = params.testing?.createProxyAgent?.(proxy) ?? createNodeProxyAgent({
|
|
6303
6452
|
mode: "explicit",
|
|
6304
6453
|
proxyUrl: proxy,
|
|
6305
6454
|
protocol: "https"
|
|
6306
6455
|
});
|
|
6307
|
-
fetchImpl = createDiscordGatewayMetadataFetch(debugProxySettings.enabled, proxy);
|
|
6456
|
+
fetchImpl = createDiscordGatewayMetadataFetch(debugProxySettings.enabled, { proxyUrl: proxy });
|
|
6308
6457
|
params.runtime.log?.("discord: gateway proxy enabled");
|
|
6309
6458
|
} catch (err) {
|
|
6310
6459
|
params.runtime.error?.(danger(`discord: invalid gateway proxy: ${String(err)}`));
|
|
@@ -6317,6 +6466,7 @@ function createDiscordGatewayPlugin(params) {
|
|
|
6317
6466
|
autoInteractions: false
|
|
6318
6467
|
},
|
|
6319
6468
|
gatewayInfoTimeoutMs,
|
|
6469
|
+
...endpoint ? { endpoint } : {},
|
|
6320
6470
|
fetchImpl,
|
|
6321
6471
|
runtime: params.runtime,
|
|
6322
6472
|
testing: params.testing,
|
|
@@ -6362,12 +6512,12 @@ function readFirstStackFrame(err) {
|
|
|
6362
6512
|
return frame ? frame.replace(/^at\s+/, "") : void 0;
|
|
6363
6513
|
}
|
|
6364
6514
|
function formatDiscordGatewayErrorMessage(err) {
|
|
6365
|
-
if (!(err instanceof Error)) return formatErrorMessage
|
|
6515
|
+
if (!(err instanceof Error)) return formatErrorMessage(err);
|
|
6366
6516
|
if (err.message) {
|
|
6367
|
-
const detail = formatErrorMessage
|
|
6517
|
+
const detail = formatErrorMessage(err);
|
|
6368
6518
|
return err.name ? `${err.name}: ${detail}` : detail;
|
|
6369
6519
|
}
|
|
6370
|
-
const detail = formatErrorMessage
|
|
6520
|
+
const detail = formatErrorMessage(err);
|
|
6371
6521
|
const firstFrame = readFirstStackFrame(err);
|
|
6372
6522
|
if (firstFrame && detail === (err.name || "Error")) return `${detail} @ ${firstFrame}`;
|
|
6373
6523
|
return detail;
|
|
@@ -6901,7 +7051,7 @@ async function runDiscordGatewayLifecycle(params) {
|
|
|
6901
7051
|
});
|
|
6902
7052
|
try {
|
|
6903
7053
|
if (drainPendingGatewayErrors() === "stop") return;
|
|
6904
|
-
if (gatewayReadyAtLifecycleStart && params.voiceManager) params.voiceManager.autoJoin().catch((err) => params.runtime.error?.(danger(`discord voice: autoJoin failed: ${formatErrorMessage
|
|
7054
|
+
if (gatewayReadyAtLifecycleStart && params.voiceManager) params.voiceManager.autoJoin().catch((err) => params.runtime.error?.(danger(`discord voice: autoJoin failed: ${formatErrorMessage(err)}`)));
|
|
6905
7055
|
await waitForGatewayReady({
|
|
6906
7056
|
gateway,
|
|
6907
7057
|
abortSignal: params.abortSignal,
|
|
@@ -6946,7 +7096,7 @@ async function runDiscordGatewayLifecycle(params) {
|
|
|
6946
7096
|
let discordVoiceRuntimePromise;
|
|
6947
7097
|
let discordProviderSessionRuntimePromise;
|
|
6948
7098
|
async function loadDiscordVoiceRuntime() {
|
|
6949
|
-
const promise = discordVoiceRuntimePromise ?? import("./voice-runtime-
|
|
7099
|
+
const promise = discordVoiceRuntimePromise ?? import("./voice-runtime-DHVQ2mFz.mjs").then((n) => n.t);
|
|
6950
7100
|
discordVoiceRuntimePromise = promise;
|
|
6951
7101
|
try {
|
|
6952
7102
|
return await promise;
|
|
@@ -6956,7 +7106,7 @@ async function loadDiscordVoiceRuntime() {
|
|
|
6956
7106
|
}
|
|
6957
7107
|
}
|
|
6958
7108
|
async function loadDiscordProviderSessionRuntime() {
|
|
6959
|
-
const promise = discordProviderSessionRuntimePromise ?? import("./provider-session.runtime-
|
|
7109
|
+
const promise = discordProviderSessionRuntimePromise ?? import("./provider-session.runtime-BW7QrF5C.mjs");
|
|
6960
7110
|
discordProviderSessionRuntimePromise = promise;
|
|
6961
7111
|
try {
|
|
6962
7112
|
return await promise;
|
|
@@ -6990,13 +7140,13 @@ function isLegacyMissingSessionError(message) {
|
|
|
6990
7140
|
function classifyAcpStatusProbeError(params) {
|
|
6991
7141
|
if (params.isAcpRuntimeError(params.error) && ["SESSION_OWNER_MIGRATION_REQUIRED", "SESSION_OWNER_UNSUPPORTED"].includes(params.error.detailCode ?? "")) return {
|
|
6992
7142
|
status: "uncertain",
|
|
6993
|
-
reason: formatErrorMessage
|
|
7143
|
+
reason: formatErrorMessage(params.error)
|
|
6994
7144
|
};
|
|
6995
7145
|
if (params.isAcpRuntimeError(params.error) && params.error.code === "ACP_SESSION_INIT_FAILED") return {
|
|
6996
7146
|
status: "stale",
|
|
6997
7147
|
reason: "session-init-failed"
|
|
6998
7148
|
};
|
|
6999
|
-
if (isLegacyMissingSessionError(formatErrorMessage
|
|
7149
|
+
if (isLegacyMissingSessionError(formatErrorMessage(params.error))) return {
|
|
7000
7150
|
status: "stale",
|
|
7001
7151
|
reason: "session-missing"
|
|
7002
7152
|
};
|
|
@@ -7060,7 +7210,12 @@ async function probeDiscordAcpBindingHealth(params) {
|
|
|
7060
7210
|
//#endregion
|
|
7061
7211
|
//#region extensions/discord/src/monitor/provider.cleanup.ts
|
|
7062
7212
|
async function cleanupDiscordProviderStartup(params) {
|
|
7063
|
-
|
|
7213
|
+
const listenersStopped = params.stopMonitorListeners?.();
|
|
7214
|
+
try {
|
|
7215
|
+
await params.deactivateMessageHandler?.();
|
|
7216
|
+
} finally {
|
|
7217
|
+
await listenersStopped;
|
|
7218
|
+
}
|
|
7064
7219
|
params.autoPresenceController?.stop();
|
|
7065
7220
|
params.setStatus?.({ connected: false });
|
|
7066
7221
|
if (params.onEarlyGatewayDebug) params.earlyGatewayEmitter?.removeListener("debug", params.onEarlyGatewayDebug);
|
|
@@ -7442,7 +7597,7 @@ function readDiscordDeployObjectField(value, field) {
|
|
|
7442
7597
|
function isAbortLikeError(err) {
|
|
7443
7598
|
if (!err || typeof err !== "object") return false;
|
|
7444
7599
|
const name = "name" in err && typeof err.name === "string" ? err.name : void 0;
|
|
7445
|
-
const message = formatErrorMessage
|
|
7600
|
+
const message = formatErrorMessage(err);
|
|
7446
7601
|
return name === "AbortError" || message === "This operation was aborted" || message === "The operation was aborted" || /\boperation was aborted\b/i.test(message);
|
|
7447
7602
|
}
|
|
7448
7603
|
function formatDiscordDeployRestOperation(err) {
|
|
@@ -7454,7 +7609,7 @@ function formatDiscordDeployRestOperation(err) {
|
|
|
7454
7609
|
return "request";
|
|
7455
7610
|
}
|
|
7456
7611
|
function formatDiscordDeployErrorMessage(err) {
|
|
7457
|
-
if (!isAbortLikeError(err)) return formatErrorMessage
|
|
7612
|
+
if (!isAbortLikeError(err)) return formatErrorMessage(err);
|
|
7458
7613
|
const deployErr = err && typeof err === "object" ? err : {};
|
|
7459
7614
|
const requestMs = parseFiniteNumber$1(deployErr.deployRequestMs);
|
|
7460
7615
|
const timeoutMs = parseFiniteNumber$1(deployErr.deployTimeoutMs);
|
|
@@ -7563,7 +7718,7 @@ function isDiscordDeployDailyCreateLimit(err) {
|
|
|
7563
7718
|
const deployErr = err;
|
|
7564
7719
|
const discordCode = parseStrictNonNegativeInteger$1(deployErr.discordCode);
|
|
7565
7720
|
const rawCode = parseStrictNonNegativeInteger$1(readDiscordDeployObjectField(deployErr.rawBody, "code"));
|
|
7566
|
-
return (discordCode === 30034 || rawCode === 30034) && /daily application command creates/i.test(formatErrorMessage
|
|
7721
|
+
return (discordCode === 30034 || rawCode === 30034) && /daily application command creates/i.test(formatErrorMessage(err));
|
|
7567
7722
|
}
|
|
7568
7723
|
//#endregion
|
|
7569
7724
|
//#region extensions/discord/src/monitor/provider.startup-log.ts
|
|
@@ -7698,7 +7853,7 @@ function runDiscordCommandDeployInBackground(params) {
|
|
|
7698
7853
|
isVerbose: params.isVerbose
|
|
7699
7854
|
});
|
|
7700
7855
|
}).catch((err) => {
|
|
7701
|
-
params.runtime.log?.(warn(`[${params.accountId}] slash command deploy failed in background (message send/receive unaffected): ${formatErrorMessage
|
|
7856
|
+
params.runtime.log?.(warn(`[${params.accountId}] slash command deploy failed in background (message send/receive unaffected): ${formatErrorMessage(err)}`));
|
|
7702
7857
|
});
|
|
7703
7858
|
}
|
|
7704
7859
|
//#endregion
|
|
@@ -8596,8 +8751,8 @@ async function deliverDiscordReply(params) {
|
|
|
8596
8751
|
}
|
|
8597
8752
|
//#endregion
|
|
8598
8753
|
//#region extensions/discord/src/monitor/agent-components.dispatch.ts
|
|
8599
|
-
const loadConversationRuntime$1 = createLazyRuntimeModule(() => import("./agent-components.runtime-CEPrf2SY.
|
|
8600
|
-
const loadTypingRuntime = createLazyRuntimeModule(() => import("./typing-
|
|
8754
|
+
const loadConversationRuntime$1 = createLazyRuntimeModule(() => import("./agent-components.runtime-CEPrf2SY.mjs"));
|
|
8755
|
+
const loadTypingRuntime = createLazyRuntimeModule(() => import("./typing-BKZL5fGj.mjs").then((n) => n.n));
|
|
8601
8756
|
function buildDiscordComponentConversationLabel(params) {
|
|
8602
8757
|
if (params.interactionCtx.isDirectMessage) return buildDirectLabel(params.interactionCtx.user);
|
|
8603
8758
|
if (params.interactionCtx.isGroupDm) return `Group DM #${params.channelCtx.channelName ?? params.interactionCtx.channelId} channel id:${params.interactionCtx.channelId}`;
|
|
@@ -8742,13 +8897,11 @@ async function dispatchDiscordComponentEvent(params) {
|
|
|
8742
8897
|
Surface: "discord",
|
|
8743
8898
|
WasMentioned: true,
|
|
8744
8899
|
CommandAuthorized: commandAuthorized,
|
|
8745
|
-
CommandTurn: {
|
|
8746
|
-
kind: "text-slash",
|
|
8747
|
-
source: "text",
|
|
8900
|
+
CommandTurn: createCommandTurnContext(params.commandSource ?? "text", {
|
|
8748
8901
|
authorized: commandAuthorized,
|
|
8749
8902
|
body: eventText
|
|
8750
|
-
},
|
|
8751
|
-
CommandSource: "text",
|
|
8903
|
+
}),
|
|
8904
|
+
CommandSource: params.commandSource ?? "text",
|
|
8752
8905
|
MessageSid: interaction.rawData.id,
|
|
8753
8906
|
Timestamp: timestamp,
|
|
8754
8907
|
OriginatingChannel: "discord",
|
|
@@ -8881,7 +9034,7 @@ async function dispatchDiscordPluginInteractiveHandler(params) {
|
|
|
8881
9034
|
}
|
|
8882
9035
|
//#endregion
|
|
8883
9036
|
//#region extensions/discord/src/monitor/agent-components.plugin-interactive.ts
|
|
8884
|
-
const loadConversationRuntime = createLazyRuntimeModule(() => import("./agent-components.runtime-CEPrf2SY.
|
|
9037
|
+
const loadConversationRuntime = createLazyRuntimeModule(() => import("./agent-components.runtime-CEPrf2SY.mjs"));
|
|
8885
9038
|
async function dispatchPluginDiscordInteractiveEvent(params) {
|
|
8886
9039
|
const normalizedConversationId = params.interactionCtx.rawGuildId || params.channelCtx.channelType === ChannelType.GroupDM ? `channel:${params.interactionCtx.channelId}` : `user:${params.interactionCtx.userId}`;
|
|
8887
9040
|
let responded = false;
|
|
@@ -9004,7 +9157,7 @@ async function dispatchPluginDiscordInteractiveEvent(params) {
|
|
|
9004
9157
|
}
|
|
9005
9158
|
//#endregion
|
|
9006
9159
|
//#region extensions/discord/src/monitor/agent-components.handlers.ts
|
|
9007
|
-
const loadComponentsRuntime = createLazyRuntimeModule(() => import("./components-
|
|
9160
|
+
const loadComponentsRuntime = createLazyRuntimeModule(() => import("./components-MqMWUWnE.mjs").then((n) => n.t));
|
|
9008
9161
|
async function handleDiscordComponentEvent(params) {
|
|
9009
9162
|
const parsed = parseDiscordComponentData(params.data, resolveInteractionCustomId(params.interaction));
|
|
9010
9163
|
if (!parsed) {
|
|
@@ -9090,6 +9243,7 @@ async function handleDiscordComponentEvent(params) {
|
|
|
9090
9243
|
channelCtx,
|
|
9091
9244
|
guildInfo,
|
|
9092
9245
|
eventText,
|
|
9246
|
+
commandSource: consumed.callbackDataKind === "command" && (buttonCallbackFallback || selectedCommandFallback) ? "native" : void 0,
|
|
9093
9247
|
replyToId: consumed.messageId ?? params.interaction.message?.id,
|
|
9094
9248
|
routeOverrides: {
|
|
9095
9249
|
sessionKey: consumed.sessionKey,
|
|
@@ -9582,11 +9736,14 @@ var ExecApprovalButton = class extends Button {
|
|
|
9582
9736
|
const terminalLabel = resolveTerminalLabel(result.resolution.approval);
|
|
9583
9737
|
let terminalized = false;
|
|
9584
9738
|
try {
|
|
9585
|
-
await interaction.
|
|
9586
|
-
|
|
9587
|
-
|
|
9588
|
-
|
|
9589
|
-
|
|
9739
|
+
if (interaction.message) terminalized = await discordApprovalMessageUpdates.enqueue(interaction.message.id, async () => {
|
|
9740
|
+
if (!hasDiscordApprovalControl(await interaction.fetchReply(), parsed)) return false;
|
|
9741
|
+
await interaction.editReply(buildTerminalPayload({
|
|
9742
|
+
approval: result.resolution.approval,
|
|
9743
|
+
applied: result.resolution.applied
|
|
9744
|
+
}));
|
|
9745
|
+
return true;
|
|
9746
|
+
});
|
|
9590
9747
|
} catch {}
|
|
9591
9748
|
if (!terminalized || !result.resolution.applied) try {
|
|
9592
9749
|
await interaction.followUp({
|
|
@@ -9937,9 +10094,13 @@ var DiscordGuildJoinIntroductionListener = class extends GuildCreateListener {
|
|
|
9937
10094
|
constructor(params) {
|
|
9938
10095
|
super();
|
|
9939
10096
|
this.params = params;
|
|
10097
|
+
this.stopped = false;
|
|
10098
|
+
this.pendingReports = /* @__PURE__ */ new Set();
|
|
9940
10099
|
}
|
|
9941
10100
|
async handle(data, client) {
|
|
10101
|
+
if (this.stopped) return;
|
|
9942
10102
|
const policy = await this.params.readPolicy?.();
|
|
10103
|
+
if (this.stopped) return;
|
|
9943
10104
|
const params = {
|
|
9944
10105
|
...this.params,
|
|
9945
10106
|
...policy
|
|
@@ -9987,6 +10148,7 @@ var DiscordGuildJoinIntroductionListener = class extends GuildCreateListener {
|
|
|
9987
10148
|
break;
|
|
9988
10149
|
}
|
|
9989
10150
|
}
|
|
10151
|
+
if (this.stopped) return;
|
|
9990
10152
|
if (policy?.isCurrent() === false) {
|
|
9991
10153
|
params.logger?.info("Discord guild join introduction skipped: access policy changed", {
|
|
9992
10154
|
guildId: data.id,
|
|
@@ -10002,7 +10164,7 @@ var DiscordGuildJoinIntroductionListener = class extends GuildCreateListener {
|
|
|
10002
10164
|
return;
|
|
10003
10165
|
}
|
|
10004
10166
|
const selectedChannel = targetChannel;
|
|
10005
|
-
|
|
10167
|
+
const report = reportChannelRoomJoin({
|
|
10006
10168
|
cfg: params.cfg,
|
|
10007
10169
|
channel: "discord",
|
|
10008
10170
|
accountId: params.accountId,
|
|
@@ -10038,6 +10200,16 @@ var DiscordGuildJoinIntroductionListener = class extends GuildCreateListener {
|
|
|
10038
10200
|
}
|
|
10039
10201
|
}
|
|
10040
10202
|
});
|
|
10203
|
+
this.pendingReports.add(report);
|
|
10204
|
+
try {
|
|
10205
|
+
await report;
|
|
10206
|
+
} finally {
|
|
10207
|
+
this.pendingReports.delete(report);
|
|
10208
|
+
}
|
|
10209
|
+
}
|
|
10210
|
+
async stop() {
|
|
10211
|
+
this.stopped = true;
|
|
10212
|
+
await Promise.allSettled(this.pendingReports);
|
|
10041
10213
|
}
|
|
10042
10214
|
};
|
|
10043
10215
|
//#endregion
|
|
@@ -10165,7 +10337,7 @@ async function fetchDiscordBotIdentity(params) {
|
|
|
10165
10337
|
function registerDiscordMonitorListeners(params) {
|
|
10166
10338
|
registerDiscordListener(params.client.listeners, new DiscordInteractionListener(params.logger, params.trackInboundEvent));
|
|
10167
10339
|
registerDiscordListener(params.client.listeners, new DiscordMessageListener(params.messageHandler, params.logger, params.trackInboundEvent));
|
|
10168
|
-
|
|
10340
|
+
const guildJoinListener = new DiscordGuildJoinIntroductionListener({
|
|
10169
10341
|
readPolicy: params.readPolicy,
|
|
10170
10342
|
cfg: params.cfg,
|
|
10171
10343
|
accountId: params.accountId,
|
|
@@ -10173,7 +10345,8 @@ function registerDiscordMonitorListeners(params) {
|
|
|
10173
10345
|
groupPolicy: params.groupPolicy,
|
|
10174
10346
|
guildEntries: params.guildEntries,
|
|
10175
10347
|
logger: params.logger
|
|
10176
|
-
})
|
|
10348
|
+
});
|
|
10349
|
+
registerDiscordListener(params.client.listeners, guildJoinListener);
|
|
10177
10350
|
const reactionListenerOptions = {
|
|
10178
10351
|
readPolicy: params.readPolicy,
|
|
10179
10352
|
cfg: params.cfg,
|
|
@@ -10193,10 +10366,13 @@ function registerDiscordMonitorListeners(params) {
|
|
|
10193
10366
|
};
|
|
10194
10367
|
registerDiscordListener(params.client.listeners, new DiscordReactionListener(reactionListenerOptions));
|
|
10195
10368
|
registerDiscordListener(params.client.listeners, new DiscordReactionRemoveListener(reactionListenerOptions));
|
|
10196
|
-
|
|
10369
|
+
const threadUpdateListener = new DiscordThreadUpdateListener(params.cfg, params.logger);
|
|
10370
|
+
registerDiscordListener(params.client.listeners, threadUpdateListener);
|
|
10371
|
+
registerDiscordListener(params.client.listeners, new DiscordThreadReadyListener(threadUpdateListener));
|
|
10197
10372
|
registerDiscordListener(params.client.listeners, new DiscordThreadDeleteListener(params.cfg, params.accountId, params.logger));
|
|
10373
|
+
let presenceListener;
|
|
10198
10374
|
if (params.discordConfig.intents?.presence) {
|
|
10199
|
-
|
|
10375
|
+
presenceListener = new DiscordPresenceListener({
|
|
10200
10376
|
readPolicy: params.readPolicy,
|
|
10201
10377
|
cfg: params.cfg,
|
|
10202
10378
|
logger: params.logger,
|
|
@@ -10210,6 +10386,14 @@ function registerDiscordMonitorListeners(params) {
|
|
|
10210
10386
|
registerDiscordListener(params.client.listeners, new DiscordPresenceReadyListener(presenceListener));
|
|
10211
10387
|
params.runtime.log?.("discord: GuildPresences intent enabled — presence listener registered");
|
|
10212
10388
|
}
|
|
10389
|
+
return async () => {
|
|
10390
|
+
const introductionsStopped = guildJoinListener.stop();
|
|
10391
|
+
try {
|
|
10392
|
+
await presenceListener?.stop();
|
|
10393
|
+
} finally {
|
|
10394
|
+
await introductionsStopped;
|
|
10395
|
+
}
|
|
10396
|
+
};
|
|
10213
10397
|
}
|
|
10214
10398
|
//#endregion
|
|
10215
10399
|
//#region extensions/discord/src/monitor/startup-status.ts
|
|
@@ -10230,7 +10414,7 @@ function logDiscordStartupPhase(params) {
|
|
|
10230
10414
|
const DISCORD_DISALLOWED_INTENTS_CODE = GatewayCloseCodes$1.DisallowedIntents;
|
|
10231
10415
|
function isDiscordDisallowedIntentsError(err) {
|
|
10232
10416
|
if (!err) return false;
|
|
10233
|
-
return formatErrorMessage
|
|
10417
|
+
return formatErrorMessage(err).includes(String(DISCORD_DISALLOWED_INTENTS_CODE));
|
|
10234
10418
|
}
|
|
10235
10419
|
async function monitorDiscordProvider(opts = {}) {
|
|
10236
10420
|
const startupStartedAt = Date.now();
|
|
@@ -10309,6 +10493,7 @@ async function monitorDiscordProvider(opts = {}) {
|
|
|
10309
10493
|
const sessionPrefix = "discord:slash";
|
|
10310
10494
|
const ephemeralDefault = slashCommand.ephemeral;
|
|
10311
10495
|
const voiceEnabled = resolveDiscordVoiceEnabled(discordCfg.voice);
|
|
10496
|
+
if (voiceEnabled && getDiscordEndpointRuntime()) throw new Error("Discord voice transport is unavailable while DISCORD_API_URL is configured");
|
|
10312
10497
|
const allowlistResolved = await resolveDiscordAllowlistConfig({
|
|
10313
10498
|
token,
|
|
10314
10499
|
guildEntries,
|
|
@@ -10361,7 +10546,7 @@ async function monitorDiscordProvider(opts = {}) {
|
|
|
10361
10546
|
if (applicationIdProbe.kind !== "resolved") {
|
|
10362
10547
|
const at = Date.now();
|
|
10363
10548
|
const terminal = applicationIdProbe.kind === "rejected";
|
|
10364
|
-
const probeError = formatErrorMessage
|
|
10549
|
+
const probeError = formatErrorMessage(applicationIdProbe.error);
|
|
10365
10550
|
const message = `Failed to resolve Discord application id: ${probeError}`;
|
|
10366
10551
|
opts.setStatus?.({
|
|
10367
10552
|
connected: false,
|
|
@@ -10395,43 +10580,46 @@ async function monitorDiscordProvider(opts = {}) {
|
|
|
10395
10580
|
listNativeCommandSpecsForConfig: discordProviderRuntime.listNativeCommandSpecsForConfig
|
|
10396
10581
|
});
|
|
10397
10582
|
const voiceManagerRef = { current: null };
|
|
10398
|
-
const threadBindings = threadBindingsEnabled ? discordProviderSessionRuntime.createThreadBindingManager({
|
|
10583
|
+
const threadBindings = threadBindingsEnabled ? await discordProviderSessionRuntime.createThreadBindingManager({
|
|
10399
10584
|
accountId: account.accountId,
|
|
10400
10585
|
token,
|
|
10401
10586
|
cfg,
|
|
10402
10587
|
idleTimeoutMs: threadBindingIdleTimeoutMs,
|
|
10403
10588
|
maxAgeMs: threadBindingMaxAgeMs
|
|
10404
10589
|
}) : discordProviderSessionRuntime.createNoopThreadBindingManager(account.accountId);
|
|
10405
|
-
if (threadBindingsEnabled) {
|
|
10406
|
-
const uncertainProbeKeys = /* @__PURE__ */ new Set();
|
|
10407
|
-
const reconciliation = await discordProviderSessionRuntime.reconcileAcpThreadBindingsOnStartup({
|
|
10408
|
-
cfg,
|
|
10409
|
-
accountId: account.accountId,
|
|
10410
|
-
sendFarewell: false,
|
|
10411
|
-
healthProbe: async ({ sessionKey, session }) => {
|
|
10412
|
-
const probe = await probeDiscordAcpBindingHealth({
|
|
10413
|
-
cfg,
|
|
10414
|
-
sessionKey,
|
|
10415
|
-
agentId: session.agentId,
|
|
10416
|
-
storedState: session.acp?.state,
|
|
10417
|
-
lastActivityAt: session.acp?.lastActivityAt,
|
|
10418
|
-
providerSessionRuntime: discordProviderSessionRuntime
|
|
10419
|
-
});
|
|
10420
|
-
if (probe.status === "uncertain") uncertainProbeKeys.add(`${sessionKey}${probe.reason ? ` (${probe.reason})` : ""}`);
|
|
10421
|
-
return probe;
|
|
10422
|
-
}
|
|
10423
|
-
});
|
|
10424
|
-
if (reconciliation.removed > 0) logVerbose(`discord: removed ${reconciliation.removed}/${reconciliation.checked} stale ACP thread bindings on startup for account ${account.accountId}: ${reconciliation.staleSessionKeys.join(", ")}`);
|
|
10425
|
-
if (uncertainProbeKeys.size > 0) logVerbose(`discord: ACP thread-binding health probe uncertain for account ${account.accountId}: ${[...uncertainProbeKeys].join(", ")}`);
|
|
10426
|
-
}
|
|
10427
10590
|
let lifecycleStarted = false;
|
|
10428
10591
|
let gatewaySupervisor;
|
|
10429
10592
|
let deactivateMessageHandler;
|
|
10593
|
+
let stopMonitorListeners;
|
|
10430
10594
|
let autoPresenceController = null;
|
|
10431
10595
|
let lifecycleGateway;
|
|
10432
10596
|
let earlyGatewayEmitter = gatewaySupervisor?.emitter;
|
|
10433
10597
|
let onEarlyGatewayDebug;
|
|
10434
10598
|
try {
|
|
10599
|
+
if (opts.abortSignal?.aborted) return;
|
|
10600
|
+
if (threadBindingsEnabled) {
|
|
10601
|
+
const uncertainProbeKeys = /* @__PURE__ */ new Set();
|
|
10602
|
+
const reconciliation = await discordProviderSessionRuntime.reconcileAcpThreadBindingsOnStartup({
|
|
10603
|
+
cfg,
|
|
10604
|
+
accountId: account.accountId,
|
|
10605
|
+
sendFarewell: false,
|
|
10606
|
+
healthProbe: async ({ sessionKey, session }) => {
|
|
10607
|
+
const probe = await probeDiscordAcpBindingHealth({
|
|
10608
|
+
cfg,
|
|
10609
|
+
sessionKey,
|
|
10610
|
+
agentId: session.agentId,
|
|
10611
|
+
storedState: session.acp?.state,
|
|
10612
|
+
lastActivityAt: session.acp?.lastActivityAt,
|
|
10613
|
+
providerSessionRuntime: discordProviderSessionRuntime
|
|
10614
|
+
});
|
|
10615
|
+
if (probe.status === "uncertain") uncertainProbeKeys.add(`${sessionKey}${probe.reason ? ` (${probe.reason})` : ""}`);
|
|
10616
|
+
return probe;
|
|
10617
|
+
}
|
|
10618
|
+
});
|
|
10619
|
+
if (reconciliation.removed > 0) logVerbose(`discord: removed ${reconciliation.removed}/${reconciliation.checked} stale ACP thread bindings on startup for account ${account.accountId}: ${reconciliation.staleSessionKeys.join(", ")}`);
|
|
10620
|
+
if (uncertainProbeKeys.size > 0) logVerbose(`discord: ACP thread-binding health probe uncertain for account ${account.accountId}: ${[...uncertainProbeKeys].join(", ")}`);
|
|
10621
|
+
}
|
|
10622
|
+
if (opts.abortSignal?.aborted) return;
|
|
10435
10623
|
const pluginChannelRuntime = opts.channelRuntime;
|
|
10436
10624
|
const { commands, components, modals } = createDiscordProviderInteractionSurface({
|
|
10437
10625
|
readPolicy,
|
|
@@ -10572,7 +10760,7 @@ async function monitorDiscordProvider(opts = {}) {
|
|
|
10572
10760
|
lastInboundAt: at
|
|
10573
10761
|
});
|
|
10574
10762
|
} : void 0;
|
|
10575
|
-
registerDiscordMonitorListeners({
|
|
10763
|
+
stopMonitorListeners = registerDiscordMonitorListeners({
|
|
10576
10764
|
readPolicy,
|
|
10577
10765
|
cfg,
|
|
10578
10766
|
client,
|
|
@@ -10622,6 +10810,7 @@ async function monitorDiscordProvider(opts = {}) {
|
|
|
10622
10810
|
} finally {
|
|
10623
10811
|
await cleanupDiscordProviderStartup({
|
|
10624
10812
|
deactivateMessageHandler,
|
|
10813
|
+
stopMonitorListeners,
|
|
10625
10814
|
autoPresenceController,
|
|
10626
10815
|
setStatus: opts.setStatus,
|
|
10627
10816
|
onEarlyGatewayDebug,
|