@openclaw/mattermost 2026.9.4 → 2026.9.6
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/.setup/channel-plugin-api-CCmaCFdK.mjs +3 -0
- package/dist/.setup/channel-plugin-api-CzBhdovL.mjs +40 -0
- package/dist/{channel-plugin-runtime-Dhr44A2Y.js → .setup/channel-plugin-runtime-yAOg5GcM.mjs} +40 -30
- package/dist/{channel.runtime-CYxC0VaI.js → .setup/channel.runtime-CihvzY84.mjs} +419 -200
- package/dist/{client-Dt7Q-j5B.js → .setup/client-BSSVve1x.mjs} +64 -22
- package/dist/{interactions-DF1FH27_.js → .setup/interactions-rBQWCbK8.mjs} +3 -3
- package/dist/{monitor-auth-C6RGYyn-.js → .setup/monitor-auth-CCpN0z_f.mjs} +18 -5
- package/dist/{normalize-R-ATEEHC.js → .setup/normalize-DM54w7ud.mjs} +47 -7
- package/dist/.setup/secret-contract-api-Drab0Nqx.mjs +3 -0
- package/dist/{slash-state-BjBTvP7u.js → .setup/slash-state-DfnmzXMr.mjs} +92 -31
- package/dist/api.js +2 -2
- package/dist/channel-plugin-api.js +2 -39
- package/dist/channel-plugin-runtime.js +1 -1
- package/dist/doctor-contract-api.js +1 -1
- package/dist/gateway-auth-api.js +1 -1
- package/dist/policy-api.js +1 -1
- package/dist/runtime-api.js +1 -1
- package/dist/secret-contract-api.js +1 -1
- package/dist/setup-entry.js +3 -2
- package/dist/slash-route-api.js +1 -1
- package/node_modules/zod/README.md +29 -2
- package/node_modules/zod/compile.cjs +96 -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 +21 -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/locales/index.cjs +19 -0
- package/node_modules/zod/mini/index.cjs +19 -0
- package/node_modules/zod/package.json +20 -8
- 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/helpers/errorUtil.ts +1 -1
- 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 +14 -9
- package/node_modules/zod/src/v4/classic/from-json-schema.ts +363 -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 +640 -375
- 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 +186 -0
- package/node_modules/zod/src/v4/classic/tests/bigint.test.ts +36 -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 +3 -3
- 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 +985 -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 +261 -13
- package/node_modules/zod/src/v4/classic/tests/enum.test.ts +20 -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 +403 -6
- package/node_modules/zod/src/v4/classic/tests/from-json-schema.test.ts +582 -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/iban.test.ts +81 -0
- 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 +319 -0
- package/node_modules/zod/src/v4/classic/tests/instanceof.test.ts +67 -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 +215 -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 +85 -9
- package/node_modules/zod/src/v4/classic/tests/object.test.ts +301 -12
- package/node_modules/zod/src/v4/classic/tests/optin-ladder.test.ts +235 -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/prefault.test.ts +70 -0
- package/node_modules/zod/src/v4/classic/tests/preprocess-types.test.ts +20 -2
- package/node_modules/zod/src/v4/classic/tests/properties.test.ts +141 -0
- 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 +79 -3
- 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/standard-schema.test.ts +19 -0
- package/node_modules/zod/src/v4/classic/tests/string.test.ts +222 -6
- 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 +44 -3
- package/node_modules/zod/src/v4/classic/tests/to-json-schema.test.ts +1812 -204
- 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 +645 -0
- package/node_modules/zod/src/v4/classic/tests/validations.test.ts +2 -2
- package/node_modules/zod/src/v4/core/api.ts +87 -35
- package/node_modules/zod/src/v4/core/checks.ts +119 -146
- package/node_modules/zod/src/v4/core/compile.ts +2313 -0
- package/node_modules/zod/src/v4/core/core.ts +99 -22
- package/node_modules/zod/src/v4/core/doc.ts +17 -9
- package/node_modules/zod/src/v4/core/errors.ts +113 -25
- package/node_modules/zod/src/v4/core/index.ts +3 -0
- package/node_modules/zod/src/v4/core/json-schema-generator.ts +8 -3
- package/node_modules/zod/src/v4/core/json-schema-processors.ts +424 -156
- package/node_modules/zod/src/v4/core/json-schema.ts +2 -1
- package/node_modules/zod/src/v4/core/memoizer.ts +331 -0
- package/node_modules/zod/src/v4/core/parse.ts +164 -50
- package/node_modules/zod/src/v4/core/regexes.ts +42 -15
- package/node_modules/zod/src/v4/core/registries.ts +2 -2
- package/node_modules/zod/src/v4/core/schemas.ts +1000 -538
- package/node_modules/zod/src/v4/core/tests/cached.test.ts +54 -0
- package/node_modules/zod/src/v4/core/tests/compile-differential.test.ts +1004 -0
- package/node_modules/zod/src/v4/core/tests/compile-generative.test.ts +445 -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 +2036 -0
- package/node_modules/zod/src/v4/core/tests/email-regex.test.ts +140 -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/tg.test.ts +85 -0
- package/node_modules/zod/src/v4/core/tests/locales/tk.test.ts +69 -0
- package/node_modules/zod/src/v4/core/tests/polyfill-collision.test.ts +46 -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 +133 -0
- package/node_modules/zod/src/v4/core/to-json-schema.ts +283 -48
- package/node_modules/zod/src/v4/core/util.ts +454 -157
- 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 +5 -0
- package/node_modules/zod/src/v4/locales/az.ts +5 -0
- package/node_modules/zod/src/v4/locales/be.ts +12 -0
- package/node_modules/zod/src/v4/locales/bg.ts +5 -0
- package/node_modules/zod/src/v4/locales/bn.ts +123 -0
- package/node_modules/zod/src/v4/locales/ca.ts +5 -0
- package/node_modules/zod/src/v4/locales/ckb.ts +140 -0
- package/node_modules/zod/src/v4/locales/cs.ts +5 -0
- package/node_modules/zod/src/v4/locales/da.ts +7 -2
- package/node_modules/zod/src/v4/locales/de.ts +5 -0
- package/node_modules/zod/src/v4/locales/el.ts +3 -0
- package/node_modules/zod/src/v4/locales/en.ts +17 -4
- package/node_modules/zod/src/v4/locales/eo.ts +5 -0
- package/node_modules/zod/src/v4/locales/es.ts +4 -0
- package/node_modules/zod/src/v4/locales/fa.ts +5 -0
- package/node_modules/zod/src/v4/locales/fi.ts +5 -0
- package/node_modules/zod/src/v4/locales/fr-CA.ts +5 -0
- package/node_modules/zod/src/v4/locales/fr.ts +21 -14
- package/node_modules/zod/src/v4/locales/gu.ts +123 -0
- package/node_modules/zod/src/v4/locales/he.ts +8 -1
- package/node_modules/zod/src/v4/locales/hi.ts +126 -0
- package/node_modules/zod/src/v4/locales/hr.ts +4 -0
- package/node_modules/zod/src/v4/locales/hu.ts +5 -0
- package/node_modules/zod/src/v4/locales/hy.ts +11 -0
- package/node_modules/zod/src/v4/locales/id.ts +5 -0
- package/node_modules/zod/src/v4/locales/index.ts +11 -0
- package/node_modules/zod/src/v4/locales/is.ts +5 -0
- package/node_modules/zod/src/v4/locales/it.ts +5 -0
- package/node_modules/zod/src/v4/locales/ja.ts +5 -0
- package/node_modules/zod/src/v4/locales/ka.ts +5 -0
- package/node_modules/zod/src/v4/locales/km.ts +5 -0
- package/node_modules/zod/src/v4/locales/kn.ts +126 -0
- package/node_modules/zod/src/v4/locales/ko.ts +5 -0
- package/node_modules/zod/src/v4/locales/lt.ts +4 -0
- package/node_modules/zod/src/v4/locales/mk.ts +5 -0
- package/node_modules/zod/src/v4/locales/ms.ts +5 -0
- package/node_modules/zod/src/v4/locales/ne.ts +128 -0
- package/node_modules/zod/src/v4/locales/nl.ts +5 -0
- package/node_modules/zod/src/v4/locales/nn.ts +121 -0
- package/node_modules/zod/src/v4/locales/no.ts +7 -2
- package/node_modules/zod/src/v4/locales/ota.ts +5 -0
- package/node_modules/zod/src/v4/locales/pl.ts +5 -0
- package/node_modules/zod/src/v4/locales/ps.ts +5 -0
- package/node_modules/zod/src/v4/locales/pt-BR.ts +161 -0
- package/node_modules/zod/src/v4/locales/pt.ts +101 -58
- package/node_modules/zod/src/v4/locales/ro.ts +3 -0
- package/node_modules/zod/src/v4/locales/ru.ts +12 -0
- package/node_modules/zod/src/v4/locales/sk.ts +123 -0
- package/node_modules/zod/src/v4/locales/sl.ts +5 -0
- package/node_modules/zod/src/v4/locales/sv.ts +7 -2
- package/node_modules/zod/src/v4/locales/ta.ts +5 -0
- package/node_modules/zod/src/v4/locales/tg.ts +135 -0
- package/node_modules/zod/src/v4/locales/th.ts +5 -0
- package/node_modules/zod/src/v4/locales/tk.ts +113 -0
- package/node_modules/zod/src/v4/locales/tr.ts +5 -0
- package/node_modules/zod/src/v4/locales/uk.ts +5 -0
- package/node_modules/zod/src/v4/locales/ur.ts +5 -0
- package/node_modules/zod/src/v4/locales/uz.ts +3 -0
- package/node_modules/zod/src/v4/locales/vi.ts +5 -0
- package/node_modules/zod/src/v4/locales/yo.ts +5 -0
- package/node_modules/zod/src/v4/locales/zh-CN.ts +5 -0
- package/node_modules/zod/src/v4/locales/zh-TW.ts +5 -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 +12 -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 +167 -63
- 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/computed.test.ts +11 -17
- 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 +158 -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/recursive-types.test.ts +16 -0
- package/node_modules/zod/src/v4/mini/tests/string.test.ts +44 -0
- package/node_modules/zod/v3/ZodError.cjs +41 -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/errors.cjs +19 -0
- package/node_modules/zod/v3/external.cjs +19 -0
- package/node_modules/zod/v3/helpers/enumUtil.cjs +19 -0
- package/node_modules/zod/v3/helpers/errorUtil.cjs +20 -1
- package/node_modules/zod/v3/helpers/errorUtil.js +1 -1
- package/node_modules/zod/v3/helpers/parseUtil.cjs +19 -0
- package/node_modules/zod/v3/helpers/partialUtil.cjs +19 -0
- package/node_modules/zod/v3/helpers/typeAliases.cjs +19 -0
- package/node_modules/zod/v3/helpers/util.cjs +19 -0
- package/node_modules/zod/v3/index.cjs +19 -0
- package/node_modules/zod/v3/standard-schema.cjs +19 -0
- package/node_modules/zod/v3/types.cjs +26 -5
- package/node_modules/zod/v3/types.js +7 -5
- package/node_modules/zod/v4/classic/checks.cjs +21 -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/coerce.cjs +19 -0
- package/node_modules/zod/v4/classic/compat.cjs +19 -0
- 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 +58 -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 +62 -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 +51 -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 +376 -75
- package/node_modules/zod/v4/classic/from-json-schema.js +357 -75
- package/node_modules/zod/v4/classic/in-out.cjs +82 -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 +21 -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 +30 -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 +23 -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 +591 -426
- package/node_modules/zod/v4/classic/schemas.d.cts +68 -19
- package/node_modules/zod/v4/classic/schemas.d.ts +68 -19
- package/node_modules/zod/v4/classic/schemas.js +564 -424
- package/node_modules/zod/v4/core/api.cjs +66 -24
- package/node_modules/zod/v4/core/api.d.cts +22 -12
- package/node_modules/zod/v4/core/api.d.ts +22 -12
- package/node_modules/zod/v4/core/api.js +44 -24
- package/node_modules/zod/v4/core/checks.cjs +88 -128
- package/node_modules/zod/v4/core/checks.d.cts +29 -13
- package/node_modules/zod/v4/core/checks.d.ts +29 -13
- package/node_modules/zod/v4/core/checks.js +68 -127
- package/node_modules/zod/v4/core/compile.cjs +1908 -0
- package/node_modules/zod/v4/core/compile.d.cts +65 -0
- package/node_modules/zod/v4/core/compile.d.ts +65 -0
- package/node_modules/zod/v4/core/compile.js +1858 -0
- package/node_modules/zod/v4/core/core.cjs +101 -19
- 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 +83 -20
- package/node_modules/zod/v4/core/doc.cjs +31 -9
- 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 +12 -9
- package/node_modules/zod/v4/core/errors.cjs +126 -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 +107 -25
- package/node_modules/zod/v4/core/index.cjs +24 -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 +24 -1
- 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 +6 -2
- package/node_modules/zod/v4/core/json-schema-processors.cjs +441 -156
- package/node_modules/zod/v4/core/json-schema-processors.d.cts +16 -0
- package/node_modules/zod/v4/core/json-schema-processors.d.ts +16 -0
- package/node_modules/zod/v4/core/json-schema-processors.js +400 -158
- package/node_modules/zod/v4/core/json-schema.cjs +19 -0
- 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 +360 -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 +311 -0
- package/node_modules/zod/v4/core/parse.cjs +148 -46
- 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 +127 -45
- package/node_modules/zod/v4/core/regexes.cjs +54 -17
- package/node_modules/zod/v4/core/regexes.d.cts +5 -0
- package/node_modules/zod/v4/core/regexes.d.ts +5 -0
- package/node_modules/zod/v4/core/regexes.js +32 -15
- package/node_modules/zod/v4/core/registries.cjs +19 -0
- package/node_modules/zod/v4/core/registries.js +2 -2
- package/node_modules/zod/v4/core/schemas.cjs +785 -386
- package/node_modules/zod/v4/core/schemas.d.cts +123 -34
- package/node_modules/zod/v4/core/schemas.d.ts +123 -34
- package/node_modules/zod/v4/core/schemas.js +753 -386
- package/node_modules/zod/v4/core/standard-schema.cjs +19 -0
- package/node_modules/zod/v4/core/to-json-schema.cjs +269 -45
- package/node_modules/zod/v4/core/to-json-schema.d.cts +45 -5
- package/node_modules/zod/v4/core/to-json-schema.d.ts +45 -5
- package/node_modules/zod/v4/core/to-json-schema.js +247 -44
- package/node_modules/zod/v4/core/util.cjs +372 -157
- package/node_modules/zod/v4/core/util.d.cts +79 -1
- package/node_modules/zod/v4/core/util.d.ts +79 -1
- package/node_modules/zod/v4/core/util.js +341 -156
- package/node_modules/zod/v4/core/versions.cjs +21 -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 +214 -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 +34 -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 +5 -0
- package/node_modules/zod/v4/locales/ar.js +5 -0
- package/node_modules/zod/v4/locales/az.cjs +5 -0
- package/node_modules/zod/v4/locales/az.js +5 -0
- package/node_modules/zod/v4/locales/be.cjs +12 -0
- package/node_modules/zod/v4/locales/be.js +12 -0
- package/node_modules/zod/v4/locales/bg.cjs +5 -0
- package/node_modules/zod/v4/locales/bg.js +5 -0
- package/node_modules/zod/v4/locales/bn.cjs +140 -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 +113 -0
- package/node_modules/zod/v4/locales/ca.cjs +5 -0
- package/node_modules/zod/v4/locales/ca.js +5 -0
- package/node_modules/zod/v4/locales/ckb.cjs +160 -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 +133 -0
- package/node_modules/zod/v4/locales/cs.cjs +5 -0
- package/node_modules/zod/v4/locales/cs.js +5 -0
- package/node_modules/zod/v4/locales/da.cjs +7 -2
- package/node_modules/zod/v4/locales/da.js +7 -2
- package/node_modules/zod/v4/locales/de.cjs +5 -0
- package/node_modules/zod/v4/locales/de.js +5 -0
- package/node_modules/zod/v4/locales/el.cjs +3 -0
- package/node_modules/zod/v4/locales/el.js +3 -0
- package/node_modules/zod/v4/locales/en.cjs +16 -4
- package/node_modules/zod/v4/locales/en.js +16 -4
- package/node_modules/zod/v4/locales/eo.cjs +5 -0
- package/node_modules/zod/v4/locales/eo.js +5 -0
- package/node_modules/zod/v4/locales/es.cjs +4 -0
- package/node_modules/zod/v4/locales/es.js +4 -0
- package/node_modules/zod/v4/locales/fa.cjs +5 -0
- package/node_modules/zod/v4/locales/fa.js +5 -0
- package/node_modules/zod/v4/locales/fi.cjs +5 -0
- package/node_modules/zod/v4/locales/fi.js +5 -0
- package/node_modules/zod/v4/locales/fr-CA.cjs +5 -0
- package/node_modules/zod/v4/locales/fr-CA.js +5 -0
- package/node_modules/zod/v4/locales/fr.cjs +18 -14
- package/node_modules/zod/v4/locales/fr.js +18 -14
- package/node_modules/zod/v4/locales/gu.cjs +140 -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 +113 -0
- package/node_modules/zod/v4/locales/he.cjs +7 -0
- package/node_modules/zod/v4/locales/he.js +7 -0
- package/node_modules/zod/v4/locales/hi.cjs +138 -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 +111 -0
- package/node_modules/zod/v4/locales/hr.cjs +4 -0
- package/node_modules/zod/v4/locales/hr.js +4 -0
- package/node_modules/zod/v4/locales/hu.cjs +5 -0
- package/node_modules/zod/v4/locales/hu.js +5 -0
- package/node_modules/zod/v4/locales/hy.cjs +11 -0
- package/node_modules/zod/v4/locales/hy.js +11 -0
- package/node_modules/zod/v4/locales/id.cjs +5 -0
- package/node_modules/zod/v4/locales/id.js +5 -0
- package/node_modules/zod/v4/locales/index.cjs +43 -2
- package/node_modules/zod/v4/locales/index.d.cts +11 -0
- package/node_modules/zod/v4/locales/index.d.ts +11 -0
- package/node_modules/zod/v4/locales/index.js +11 -0
- package/node_modules/zod/v4/locales/is.cjs +5 -0
- package/node_modules/zod/v4/locales/is.js +5 -0
- package/node_modules/zod/v4/locales/it.cjs +5 -0
- package/node_modules/zod/v4/locales/it.js +5 -0
- package/node_modules/zod/v4/locales/ja.cjs +5 -0
- package/node_modules/zod/v4/locales/ja.js +5 -0
- package/node_modules/zod/v4/locales/ka.cjs +5 -0
- package/node_modules/zod/v4/locales/ka.js +5 -0
- package/node_modules/zod/v4/locales/km.cjs +5 -0
- package/node_modules/zod/v4/locales/km.js +5 -0
- package/node_modules/zod/v4/locales/kn.cjs +143 -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 +116 -0
- package/node_modules/zod/v4/locales/ko.cjs +5 -0
- package/node_modules/zod/v4/locales/ko.js +5 -0
- package/node_modules/zod/v4/locales/lt.cjs +4 -0
- package/node_modules/zod/v4/locales/lt.js +4 -0
- package/node_modules/zod/v4/locales/mk.cjs +5 -0
- package/node_modules/zod/v4/locales/mk.js +5 -0
- package/node_modules/zod/v4/locales/ms.cjs +5 -0
- package/node_modules/zod/v4/locales/ms.js +5 -0
- package/node_modules/zod/v4/locales/ne.cjs +138 -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 +111 -0
- package/node_modules/zod/v4/locales/nl.cjs +5 -0
- package/node_modules/zod/v4/locales/nl.js +5 -0
- package/node_modules/zod/v4/locales/nn.cjs +140 -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 +113 -0
- package/node_modules/zod/v4/locales/no.cjs +7 -2
- package/node_modules/zod/v4/locales/no.js +7 -2
- package/node_modules/zod/v4/locales/ota.cjs +5 -0
- package/node_modules/zod/v4/locales/ota.js +5 -0
- package/node_modules/zod/v4/locales/pl.cjs +5 -0
- package/node_modules/zod/v4/locales/pl.js +5 -0
- package/node_modules/zod/v4/locales/ps.cjs +5 -0
- package/node_modules/zod/v4/locales/ps.js +5 -0
- package/node_modules/zod/v4/locales/pt-BR.cjs +170 -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 +143 -0
- package/node_modules/zod/v4/locales/pt.cjs +89 -55
- package/node_modules/zod/v4/locales/pt.js +89 -55
- package/node_modules/zod/v4/locales/ro.cjs +3 -0
- package/node_modules/zod/v4/locales/ro.js +3 -0
- package/node_modules/zod/v4/locales/ru.cjs +12 -0
- package/node_modules/zod/v4/locales/ru.js +12 -0
- package/node_modules/zod/v4/locales/sk.cjs +143 -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 +116 -0
- package/node_modules/zod/v4/locales/sl.cjs +5 -0
- package/node_modules/zod/v4/locales/sl.js +5 -0
- package/node_modules/zod/v4/locales/sv.cjs +7 -2
- package/node_modules/zod/v4/locales/sv.js +7 -2
- package/node_modules/zod/v4/locales/ta.cjs +5 -0
- package/node_modules/zod/v4/locales/ta.js +5 -0
- package/node_modules/zod/v4/locales/tg.cjs +144 -0
- package/node_modules/zod/v4/locales/tg.d.cts +5 -0
- package/node_modules/zod/v4/locales/tg.d.ts +4 -0
- package/node_modules/zod/v4/locales/tg.js +117 -0
- package/node_modules/zod/v4/locales/th.cjs +5 -0
- package/node_modules/zod/v4/locales/th.js +5 -0
- package/node_modules/zod/v4/locales/tk.cjs +134 -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 +107 -0
- package/node_modules/zod/v4/locales/tr.cjs +5 -0
- package/node_modules/zod/v4/locales/tr.js +5 -0
- package/node_modules/zod/v4/locales/uk.cjs +5 -0
- package/node_modules/zod/v4/locales/uk.js +5 -0
- package/node_modules/zod/v4/locales/ur.cjs +5 -0
- package/node_modules/zod/v4/locales/ur.js +5 -0
- package/node_modules/zod/v4/locales/uz.cjs +3 -0
- package/node_modules/zod/v4/locales/uz.js +3 -0
- package/node_modules/zod/v4/locales/vi.cjs +5 -0
- package/node_modules/zod/v4/locales/vi.js +5 -0
- package/node_modules/zod/v4/locales/yo.cjs +5 -0
- package/node_modules/zod/v4/locales/yo.js +5 -0
- package/node_modules/zod/v4/locales/zh-CN.cjs +5 -0
- package/node_modules/zod/v4/locales/zh-CN.js +5 -0
- package/node_modules/zod/v4/locales/zh-TW.cjs +5 -0
- package/node_modules/zod/v4/locales/zh-TW.js +5 -0
- package/node_modules/zod/v4/mini/checks.cjs +21 -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/coerce.cjs +19 -0
- package/node_modules/zod/v4/mini/deep-partial.cjs +58 -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 +33 -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 +82 -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/index.cjs +19 -0
- package/node_modules/zod/v4/mini/iso.cjs +19 -0
- package/node_modules/zod/v4/mini/parse.cjs +22 -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 +117 -53
- package/node_modules/zod/v4/mini/schemas.d.cts +49 -14
- package/node_modules/zod/v4/mini/schemas.d.ts +49 -14
- package/node_modules/zod/v4/mini/schemas.js +92 -51
- package/node_modules/zod/v4-mini/index.cjs +19 -0
- package/openclaw.plugin.json +13 -29
- package/package.json +8 -8
- package/node_modules/ws/LICENSE +0 -20
- package/node_modules/ws/README.md +0 -548
- package/node_modules/ws/browser.js +0 -8
- package/node_modules/ws/index.js +0 -22
- package/node_modules/ws/lib/buffer-util.js +0 -131
- package/node_modules/ws/lib/constants.js +0 -19
- package/node_modules/ws/lib/event-target.js +0 -292
- package/node_modules/ws/lib/extension.js +0 -203
- package/node_modules/ws/lib/limiter.js +0 -55
- package/node_modules/ws/lib/permessage-deflate.js +0 -530
- package/node_modules/ws/lib/receiver.js +0 -743
- package/node_modules/ws/lib/sender.js +0 -607
- package/node_modules/ws/lib/stream.js +0 -161
- package/node_modules/ws/lib/subprotocol.js +0 -62
- package/node_modules/ws/lib/validation.js +0 -152
- package/node_modules/ws/lib/websocket-server.js +0 -562
- package/node_modules/ws/lib/websocket.js +0 -1407
- package/node_modules/ws/package.json +0 -74
- package/node_modules/ws/wrapper.mjs +0 -21
- package/node_modules/zod/src/v4/core/config.ts +0 -15
- /package/dist/{doctor-contract-mvORF4f6.js → .setup/doctor-contract-mvORF4f6.mjs} +0 -0
- /package/dist/{gateway-auth-bypass-B93t91oq.js → .setup/gateway-auth-bypass-B93t91oq.mjs} +0 -0
- /package/dist/{ingress-identity-DNl4yQSc.js → .setup/ingress-identity-DNl4yQSc.mjs} +0 -0
- /package/dist/{runtime-CNB4YGqJ.js → .setup/runtime-CNB4YGqJ.mjs} +0 -0
- /package/dist/{secret-contract-qg3NXRlS.js → .setup/secret-contract-qg3NXRlS.mjs} +0 -0
|
@@ -1,11 +1,10 @@
|
|
|
1
|
-
import { n as getOptionalMattermostRuntime, t as getMattermostRuntime } from "./runtime-CNB4YGqJ.
|
|
2
|
-
import { a as resolveInteractionCallbackPath, c as setInteractionSecret, i as createMattermostInteractionHandler, n as buildButtonProps, r as computeInteractionCallbackUrl, s as setInteractionCallbackUrl } from "./interactions-
|
|
3
|
-
import { _ as
|
|
4
|
-
import { C as resolveDefaultGroupPolicy,
|
|
5
|
-
import { n as normalizeMattermostAllowEntry } from "./ingress-identity-DNl4yQSc.
|
|
6
|
-
import {
|
|
7
|
-
import { _ as registerSlashCommands, a as sendMessageMattermost, c as joinMattermostVisibleContent, d as renderMattermostModelsPickerView, f as renderMattermostProviderPickerView, g as isSlashCommandsEnabled, h as cleanupSlashCommands, l as buildMattermostAllowedModelRefs, m as DEFAULT_COMMAND_SPECS, n as deactivateSlashCommands, o as resolveMattermostOpaqueTarget, p as resolveMattermostModelPickerCurrentModel, r as getSlashCommandState, s as deliverMattermostReplyPayload, t as activateSlashCommands, u as parseMattermostModelPickerContext, v as resolveCallbackUrl, y as resolveSlashCommandConfig } from "./slash-state-
|
|
8
|
-
import { createRequire } from "node:module";
|
|
1
|
+
import { n as getOptionalMattermostRuntime, t as getMattermostRuntime } from "./runtime-CNB4YGqJ.mjs";
|
|
2
|
+
import { a as resolveInteractionCallbackPath, c as setInteractionSecret, i as createMattermostInteractionHandler, n as buildButtonProps, r as computeInteractionCallbackUrl, s as setInteractionCallbackUrl } from "./interactions-rBQWCbK8.mjs";
|
|
3
|
+
import { _ as readMattermostError, a as createMattermostPost, d as fetchMattermostUser, h as normalizeMattermostBaseUrl, l as fetchMattermostChannelPosts, m as isRetryableError, n as buildMattermostApiUrl, o as deleteMattermostPost, p as fetchMattermostUserTeams, r as createMattermostClient, s as fetchMattermostChannel, t as MattermostPostSchema, u as fetchMattermostMe, v as sendMattermostTyping, y as updateMattermostPost } from "./client-BSSVve1x.mjs";
|
|
4
|
+
import { C as resolveAllowlistProviderRuntimeGroupPolicy$1, E as resolveDefaultGroupPolicy, O as warnMissingProviderGroupPolicyFallbackOnce, S as registerPluginHttpRoute, _ as listSkillCommandsForAgents, a as resolveMattermostMonitorInboundAccess, b as logTypingFailure, c as DEFAULT_GROUP_HISTORY_LIMIT, d as createChannelMessageReplyPipeline, f as createChannelPairingController, l as buildPreparedModelsProviderData, m as isDangerousNameMatchingEnabled, n as formatMattermostDirectMessageDropLog, o as resolveMattermostTrustedChatKind, s as shouldRetainMattermostSenderHistory, t as authorizeMattermostCommandInvocation, u as createChannelHistoryWindow, w as resolveChannelMediaMaxBytes, y as logInboundDrop } from "./monitor-auth-CCpN0z_f.mjs";
|
|
5
|
+
import { n as normalizeMattermostAllowEntry } from "./ingress-identity-DNl4yQSc.mjs";
|
|
6
|
+
import { c as listMattermostAccountIds, d as resolveMattermostReplyToMode, n as normalizeMattermostMessagingTarget, o as inspectMattermostAccount, r as parseMattermostQuestionContext, u as resolveMattermostAccount } from "./normalize-DM54w7ud.mjs";
|
|
7
|
+
import { _ as registerSlashCommands, a as sendMessageMattermost, c as joinMattermostVisibleContent, d as renderMattermostModelsPickerView, f as renderMattermostProviderPickerView, g as isSlashCommandsEnabled, h as cleanupSlashCommands, l as buildMattermostAllowedModelRefs, m as DEFAULT_COMMAND_SPECS, n as deactivateSlashCommands, o as resolveMattermostOpaqueTarget, p as resolveMattermostModelPickerCurrentModel, r as getSlashCommandState, s as deliverMattermostReplyPayload, t as activateSlashCommands, u as parseMattermostModelPickerContext, v as resolveCallbackUrl, y as resolveSlashCommandConfig } from "./slash-state-DfnmzXMr.mjs";
|
|
9
8
|
import { randomUUID } from "node:crypto";
|
|
10
9
|
import { resolveGatewayPort } from "openclaw/plugin-sdk/gateway-config-runtime";
|
|
11
10
|
import { resolvePinnedMainDmOwnerFromAllowlist, sanitizeUntrustedFileName } from "openclaw/plugin-sdk/security-runtime";
|
|
@@ -13,11 +12,11 @@ import { normalizeLowercaseStringOrEmpty, normalizeOptionalString, normalizeStri
|
|
|
13
12
|
import { buildChannelInboundMediaPayload, createAcceptedChannelDeliveryResult, createChannelPartialDeliveryError, formatInboundEnvelope, formatInboundFromLabel, formatInboundMediaUnavailableText, formatMediaPlaceholderText, implicitMentionKindWhen, isChannelPartialDeliveryError, resolveInboundMentionDecision, resolveInboundSessionEnvelopeContext, toInboundMediaFactsWithMetadata } from "openclaw/plugin-sdk/channel-inbound";
|
|
14
13
|
import { formatErrorMessage, toErrorObject } from "openclaw/plugin-sdk/error-runtime";
|
|
15
14
|
import { safeParseJsonWithSchema, safeParseWithSchema } from "openclaw/plugin-sdk/extension-shared";
|
|
16
|
-
import { asDateTimestampMs, resolveExpiresAtMsFromDurationMs, resolveTimerTimeoutMs } from "openclaw/plugin-sdk/number-runtime";
|
|
15
|
+
import { asDateTimestampMs, resolveExpiresAtMsFromDurationMs, resolvePromptHistoryLimit, resolveTimerTimeoutMs } from "openclaw/plugin-sdk/number-runtime";
|
|
17
16
|
import { readProviderJsonResponse } from "openclaw/plugin-sdk/provider-http";
|
|
18
17
|
import { fetchWithSsrFGuard, isPrivateNetworkOptInEnabled, ssrfPolicyFromPrivateNetworkOptIn } from "openclaw/plugin-sdk/ssrf-runtime";
|
|
19
18
|
import { z } from "zod";
|
|
20
|
-
import { bindIngressLifecycleToReplyOptions,
|
|
19
|
+
import { bindIngressLifecycleToReplyOptions, createChannelIngressError, createChannelIngressMonitor, createChannelProgressDraftCompositor, createFinalizableDraftLifecycle, createLivePreviewLifecycle, createMessageReceiptFromOutboundResults, createPreviewMessageReceipt, listMessageReceiptPlatformIds, resolveChannelStreamingPreviewToolProgress } from "openclaw/plugin-sdk/channel-outbound";
|
|
21
20
|
import { resolveAllowlistProviderRuntimeGroupPolicy } from "openclaw/plugin-sdk/runtime-group-policy";
|
|
22
21
|
import { rawDataToString } from "openclaw/plugin-sdk/webhook-ingress";
|
|
23
22
|
import { runDetachedWebhookWork } from "openclaw/plugin-sdk/webhook-request-guards";
|
|
@@ -26,6 +25,7 @@ import { resolveChannelGroups, resolveChannelGroupsConfigPath } from "openclaw/p
|
|
|
26
25
|
import { buildTtsSupplementMediaPayload, countOutboundMedia, getReplyPayloadTtsSupplement, isReasoningReplyPayload, resolveSendableOutboundReplyParts } from "openclaw/plugin-sdk/reply-payload";
|
|
27
26
|
import { normalizeAccountId } from "openclaw/plugin-sdk/account-id";
|
|
28
27
|
import { isRecord } from "openclaw/plugin-sdk/channel-secret-basic-runtime";
|
|
28
|
+
import { getSessionEntry, resolveStorePath } from "openclaw/plugin-sdk/session-store-runtime";
|
|
29
29
|
import { resolveInboundLastRouteSessionKey, resolveThreadSessionKeys } from "openclaw/plugin-sdk/routing";
|
|
30
30
|
import { escapeRegExp, runChannelProbe, sliceUtf16Safe, truncateUtf16Safe } from "openclaw/plugin-sdk/text-utility-runtime";
|
|
31
31
|
import { resolveHumanDelayConfig } from "openclaw/plugin-sdk/agent-runtime";
|
|
@@ -34,8 +34,8 @@ import { pruneMapToMaxSize } from "openclaw/plugin-sdk/collection-runtime";
|
|
|
34
34
|
import { channelReadyPatch, isLoopbackHost } from "openclaw/plugin-sdk/gateway-runtime";
|
|
35
35
|
import { createRuntimeConfigReader } from "openclaw/plugin-sdk/runtime-config-snapshot";
|
|
36
36
|
import { captureWsEvent, createDebugProxyWebSocketAgent, resolveDebugProxySettings } from "openclaw/plugin-sdk/proxy-capture";
|
|
37
|
-
import
|
|
38
|
-
import {
|
|
37
|
+
import { WebSocket } from "openclaw/plugin-sdk/websocket-runtime";
|
|
38
|
+
import { questionGatewayRuntime } from "openclaw/plugin-sdk/question-gateway-runtime";
|
|
39
39
|
import { getGlobalHookRunner } from "openclaw/plugin-sdk/plugin-runtime";
|
|
40
40
|
import { chunkMarkdownTextWithMode } from "openclaw/plugin-sdk/reply-chunking";
|
|
41
41
|
import { createPersistentDedupeCache } from "openclaw/plugin-sdk/dedupe-runtime";
|
|
@@ -217,10 +217,6 @@ function shouldDropEmptyMattermostBody(params) {
|
|
|
217
217
|
return !botUsername || normalizeLowercaseStringOrEmpty(bareMention ?? "") !== `@${botUsername}`;
|
|
218
218
|
}
|
|
219
219
|
//#endregion
|
|
220
|
-
//#region extensions/mattermost/src/mattermost/ws-runtime.ts
|
|
221
|
-
const require = createRequire(import.meta.url);
|
|
222
|
-
const WebSocket = require(path.join(path.dirname(require.resolve("ws/package.json")), "index.js"));
|
|
223
|
-
//#endregion
|
|
224
220
|
//#region extensions/mattermost/src/mattermost/monitor-websocket.ts
|
|
225
221
|
const MATTERMOST_WEBSOCKET_MAX_PAYLOAD_BYTES = 16777216;
|
|
226
222
|
const MATTERMOST_WEBSOCKET_HANDSHAKE_TIMEOUT_MS = 3e4;
|
|
@@ -769,7 +765,7 @@ function resolveMattermostThreadSessionContext(params) {
|
|
|
769
765
|
};
|
|
770
766
|
}
|
|
771
767
|
function resolveMattermostPendingHistoryKey(params) {
|
|
772
|
-
return params.kind === "direct" ? null : params.sessionKey;
|
|
768
|
+
return params.kind === "direct" && !params.threadRootId ? null : params.sessionKey;
|
|
773
769
|
}
|
|
774
770
|
function resolveMattermostReactionChannelId(payload) {
|
|
775
771
|
return normalizeOptionalString(payload.broadcast?.channel_id) ?? normalizeOptionalString(payload.data?.channel_id);
|
|
@@ -865,10 +861,65 @@ async function buildMattermostEventPlan(monitor, params) {
|
|
|
865
861
|
}
|
|
866
862
|
//#endregion
|
|
867
863
|
//#region extensions/mattermost/src/mattermost/monitor-interactions.ts
|
|
864
|
+
/**
|
|
865
|
+
* Answer an ask_user question from the button its own prompt offered.
|
|
866
|
+
*
|
|
867
|
+
* The Gateway owns the answer, so this consumes the click instead of letting it
|
|
868
|
+
* fall through to the synthetic `[Button click: ...]` message the generic path
|
|
869
|
+
* sends; that message would reach the agent as prose while the question stayed
|
|
870
|
+
* open.
|
|
871
|
+
*/
|
|
872
|
+
function createMattermostQuestionInteractionHandler(monitor) {
|
|
873
|
+
const { account, cfg, core, pairing, resources, runtime } = monitor;
|
|
874
|
+
return async (interaction) => {
|
|
875
|
+
const selection = parseMattermostQuestionContext(interaction.context);
|
|
876
|
+
if (!selection) return null;
|
|
877
|
+
const channelInfo = await resources.resolveChannelInfo(interaction.payload.channel_id);
|
|
878
|
+
const decide = async () => await authorizeMattermostCommandInvocation({
|
|
879
|
+
account,
|
|
880
|
+
cfg,
|
|
881
|
+
senderId: interaction.payload.user_id,
|
|
882
|
+
senderName: interaction.userName,
|
|
883
|
+
channelId: interaction.payload.channel_id,
|
|
884
|
+
channelInfo,
|
|
885
|
+
readStoreAllowFrom: pairing.readAllowFromStore,
|
|
886
|
+
allowTextCommands: core.channel.commands.shouldHandleTextCommands({
|
|
887
|
+
cfg,
|
|
888
|
+
surface: "mattermost"
|
|
889
|
+
}),
|
|
890
|
+
hasControlCommand: false
|
|
891
|
+
});
|
|
892
|
+
const auth = await decide();
|
|
893
|
+
if (!auth.ok) return { ephemeral_text: `OpenClaw ignored this action for ${auth.roomLabel}.` };
|
|
894
|
+
try {
|
|
895
|
+
const result = await questionGatewayRuntime.resolveOption({
|
|
896
|
+
cfg,
|
|
897
|
+
questionId: selection.questionId,
|
|
898
|
+
optionIndex: selection.optionIndex,
|
|
899
|
+
senderId: interaction.payload.user_id,
|
|
900
|
+
clientDisplayName: `Mattermost question (${account.accountId})`,
|
|
901
|
+
authorize: async () => (await decide()).ok
|
|
902
|
+
});
|
|
903
|
+
if (result.status === "denied") return { ephemeral_text: `OpenClaw ignored this action for ${auth.roomLabel}.` };
|
|
904
|
+
if (result.status !== "answered") return { ephemeral_text: "This question was already answered." };
|
|
905
|
+
} catch (err) {
|
|
906
|
+
runtime.error?.(`mattermost question interaction failed: ${String(err)}`);
|
|
907
|
+
return { ephemeral_text: "Could not submit this answer." };
|
|
908
|
+
}
|
|
909
|
+
return {
|
|
910
|
+
update: {
|
|
911
|
+
message: interaction.post.message ?? "",
|
|
912
|
+
props: { attachments: [{ text: `✓ **${interaction.actionName}** selected by @${interaction.userName}` }] }
|
|
913
|
+
},
|
|
914
|
+
ephemeral_text: "Answer submitted."
|
|
915
|
+
};
|
|
916
|
+
};
|
|
917
|
+
}
|
|
868
918
|
function registerMattermostInteractions(params) {
|
|
869
919
|
const { monitor } = params;
|
|
870
920
|
const { account, botUserId, cfg, client, core, pairing, resources, runtime } = monitor;
|
|
871
921
|
const { resolveChannelInfo } = resources;
|
|
922
|
+
const handleQuestionInteraction = createMattermostQuestionInteractionHandler(monitor);
|
|
872
923
|
return registerPluginHttpRoute({
|
|
873
924
|
path: params.interactionPath,
|
|
874
925
|
fallbackPath: "/mattermost/interactions/default",
|
|
@@ -880,8 +931,8 @@ function registerMattermostInteractions(params) {
|
|
|
880
931
|
allowedSourceIps: params.allowedSourceIps,
|
|
881
932
|
trustedProxies: cfg.gateway?.trustedProxies,
|
|
882
933
|
allowRealIpFallback: cfg.gateway?.allowRealIpFallback === true,
|
|
883
|
-
handleInteraction: params.handleModelPickerInteraction,
|
|
884
|
-
authorizeButtonClick: async ({ payload
|
|
934
|
+
handleInteraction: async (interaction) => await handleQuestionInteraction(interaction) ?? await params.handleModelPickerInteraction(interaction),
|
|
935
|
+
authorizeButtonClick: async ({ payload }) => {
|
|
885
936
|
const channelInfo = await resolveChannelInfo(payload.channel_id);
|
|
886
937
|
const allowTextCommands = core.channel.commands.shouldHandleTextCommands({
|
|
887
938
|
cfg,
|
|
@@ -901,13 +952,7 @@ function registerMattermostInteractions(params) {
|
|
|
901
952
|
if (decision.ok) return { ok: true };
|
|
902
953
|
return {
|
|
903
954
|
ok: false,
|
|
904
|
-
response: {
|
|
905
|
-
update: {
|
|
906
|
-
message: post.message ?? "",
|
|
907
|
-
props: post.props ?? void 0
|
|
908
|
-
},
|
|
909
|
-
ephemeral_text: `OpenClaw ignored this action for ${decision.roomLabel}.`
|
|
910
|
-
}
|
|
955
|
+
response: { ephemeral_text: `OpenClaw ignored this action for ${decision.roomLabel}.` }
|
|
911
956
|
};
|
|
912
957
|
},
|
|
913
958
|
resolveSessionKey: async ({ channelId, userId, post }) => {
|
|
@@ -1073,12 +1118,6 @@ function createMattermostModelPickerInteractionHandler(monitor) {
|
|
|
1073
1118
|
const pickerState = parseMattermostModelPickerContext(params.context);
|
|
1074
1119
|
if (!pickerState) return null;
|
|
1075
1120
|
if (pickerState.ownerUserId !== params.payload.user_id) return { ephemeral_text: "Only the person who opened this picker can use it." };
|
|
1076
|
-
const updatePickerPost = (message, buttons) => updateModelPickerPost({
|
|
1077
|
-
channelId: params.payload.channel_id,
|
|
1078
|
-
postId: params.payload.post_id,
|
|
1079
|
-
message,
|
|
1080
|
-
buttons
|
|
1081
|
-
});
|
|
1082
1121
|
const channelInfo = await resolveChannelInfo(params.payload.channel_id);
|
|
1083
1122
|
const pickerCommandText = pickerState.action === "select" ? `/model ${pickerState.provider}/${pickerState.model}` : pickerState.action === "list" ? `/models ${pickerState.provider}` : "/models";
|
|
1084
1123
|
const allowTextCommands = core.channel.commands.shouldHandleTextCommands({
|
|
@@ -1127,7 +1166,18 @@ function createMattermostModelPickerInteractionHandler(monitor) {
|
|
|
1127
1166
|
agentId: eventPlan.route.agentId,
|
|
1128
1167
|
sessionKey: eventPlan.thread.sessionKey
|
|
1129
1168
|
};
|
|
1130
|
-
const
|
|
1169
|
+
const sessionEntry = getSessionEntry({
|
|
1170
|
+
storePath: resolveStorePath(cfg.session?.store, { agentId: modelSessionRoute.agentId }),
|
|
1171
|
+
sessionKey: modelSessionRoute.sessionKey,
|
|
1172
|
+
readConsistency: "latest"
|
|
1173
|
+
});
|
|
1174
|
+
const data = await buildPreparedModelsProviderData(cfg, eventPlan.route.agentId, { sessionEntry });
|
|
1175
|
+
const updatePickerPost = (message, buttons) => updateModelPickerPost({
|
|
1176
|
+
channelId: params.payload.channel_id,
|
|
1177
|
+
postId: params.payload.post_id,
|
|
1178
|
+
message: [data.refreshWarning, message].filter(Boolean).join("\n\n"),
|
|
1179
|
+
buttons
|
|
1180
|
+
});
|
|
1131
1181
|
if (data.providers.length === 0) return await updatePickerPost("No models available.");
|
|
1132
1182
|
if (pickerState.action === "providers" || pickerState.action === "back") {
|
|
1133
1183
|
const currentModel = resolveMattermostModelPickerCurrentModel({
|
|
@@ -1250,11 +1300,16 @@ async function buildMattermostInboundMediaPayload(media) {
|
|
|
1250
1300
|
function formatMattermostPendingMediaText(params) {
|
|
1251
1301
|
return [params.body, formatMediaPlaceholderText(params.media)].filter(Boolean).join("\n").trim();
|
|
1252
1302
|
}
|
|
1303
|
+
function sanitizeOptionalAttachmentName(fileName) {
|
|
1304
|
+
const sanitized = sanitizeUntrustedFileName(fileName, "_");
|
|
1305
|
+
if (sanitized === "_" && sanitizeUntrustedFileName(fileName, "-") === "-") return "";
|
|
1306
|
+
return sanitized;
|
|
1307
|
+
}
|
|
1253
1308
|
function formatMattermostInboundMediaText(params) {
|
|
1254
1309
|
const materializedCount = params.materializedMedia.filter((media) => Boolean(media.path) || Boolean(media.url)).length;
|
|
1255
1310
|
const unavailableCount = Math.max(0, params.nativeMedia.length - materializedCount);
|
|
1256
1311
|
if (unavailableCount === 0) return params.body;
|
|
1257
|
-
const unavailableFileNames = params.materializedMedia.filter((media) => !media.path && !media.url && media.fileName).map((media) =>
|
|
1312
|
+
const unavailableFileNames = params.materializedMedia.filter((media) => !media.path && !media.url && media.fileName).map((media) => sanitizeOptionalAttachmentName(media.fileName ?? "")).filter(Boolean).join(", ");
|
|
1258
1313
|
const fileNameNotice = unavailableFileNames ? ` ${JSON.stringify(truncateUtf16Safe(unavailableFileNames, 512))}` : "";
|
|
1259
1314
|
return formatInboundMediaUnavailableText({
|
|
1260
1315
|
body: params.body,
|
|
@@ -1391,6 +1446,212 @@ function createMattermostMonitorResources(params) {
|
|
|
1391
1446
|
};
|
|
1392
1447
|
}
|
|
1393
1448
|
//#endregion
|
|
1449
|
+
//#region extensions/mattermost/src/mattermost/monitor-thread-backfill.ts
|
|
1450
|
+
const TIMEOUT_MS = 5e3;
|
|
1451
|
+
const COOLDOWN_MS = 6e4;
|
|
1452
|
+
const MAX_ATTEMPTS = 3;
|
|
1453
|
+
const MAX_RECOVERIES = 1e3;
|
|
1454
|
+
const MAX_IN_FLIGHT = 8;
|
|
1455
|
+
const MAX_THREAD_POSTS = 200;
|
|
1456
|
+
const ThreadSchema = z.object({
|
|
1457
|
+
order: z.array(z.string()),
|
|
1458
|
+
posts: z.record(z.string(), MattermostPostSchema)
|
|
1459
|
+
});
|
|
1460
|
+
/** Recovery and pending history share one monitor lifetime, never a durable shadow store. */
|
|
1461
|
+
function createMattermostThreadBackfill(params) {
|
|
1462
|
+
const { monitor, channelHistories, historyLimit } = params;
|
|
1463
|
+
const { account, cfg, client } = monitor;
|
|
1464
|
+
const histories = createChannelHistoryWindow({ historyMap: channelHistories });
|
|
1465
|
+
const recoveries = /* @__PURE__ */ new Map();
|
|
1466
|
+
const inFlight = /* @__PURE__ */ new Set();
|
|
1467
|
+
const readIdentity = (turn) => {
|
|
1468
|
+
const entry = getSessionEntry({
|
|
1469
|
+
agentId: turn.agentId,
|
|
1470
|
+
storePath: resolveStorePath(cfg.session?.store, { agentId: turn.agentId }),
|
|
1471
|
+
sessionKey: turn.historyKey,
|
|
1472
|
+
readConsistency: "latest"
|
|
1473
|
+
});
|
|
1474
|
+
return entry ? JSON.stringify([entry.sessionId ?? null, entry.lifecycleRevision ?? null]) : null;
|
|
1475
|
+
};
|
|
1476
|
+
const owns = (turn, recovery) => {
|
|
1477
|
+
if (recoveries.get(turn.historyKey) !== recovery) return false;
|
|
1478
|
+
try {
|
|
1479
|
+
return readIdentity(turn) === recovery.identity;
|
|
1480
|
+
} catch {
|
|
1481
|
+
return false;
|
|
1482
|
+
}
|
|
1483
|
+
};
|
|
1484
|
+
const touch = (key, recovery) => {
|
|
1485
|
+
recoveries.delete(key);
|
|
1486
|
+
recoveries.set(key, recovery);
|
|
1487
|
+
for (const [oldKey, old] of recoveries) {
|
|
1488
|
+
if (recoveries.size <= MAX_RECOVERIES) break;
|
|
1489
|
+
if (!old.completion) recoveries.delete(oldKey);
|
|
1490
|
+
}
|
|
1491
|
+
};
|
|
1492
|
+
const fetchEntries = async (turn, signal) => {
|
|
1493
|
+
const query = new URLSearchParams({
|
|
1494
|
+
perPage: String(Math.min(historyLimit + 1, MAX_THREAD_POSTS)),
|
|
1495
|
+
direction: "up",
|
|
1496
|
+
fromPost: turn.currentPostId,
|
|
1497
|
+
fromCreateAt: String(turn.currentPostTimestamp)
|
|
1498
|
+
});
|
|
1499
|
+
const raw = await client.request(`/posts/${encodeURIComponent(turn.threadRootId)}/thread?${query}`, {
|
|
1500
|
+
signal,
|
|
1501
|
+
timeoutMs: TIMEOUT_MS
|
|
1502
|
+
});
|
|
1503
|
+
signal.throwIfAborted();
|
|
1504
|
+
const thread = ThreadSchema.parse(raw);
|
|
1505
|
+
const candidates = thread.order.slice(0, MAX_THREAD_POSTS).flatMap((id) => {
|
|
1506
|
+
const post = thread.posts[id];
|
|
1507
|
+
if (!post || post.id !== id || post.id === turn.currentPostId || post.channel_id !== turn.channelId || post.id !== turn.threadRootId && post.root_id !== turn.threadRootId || post.type || !post.user_id || typeof post.create_at !== "number" || post.create_at > turn.currentPostTimestamp || !post.message?.trim() && !post.file_ids?.length) return [];
|
|
1508
|
+
return [post];
|
|
1509
|
+
});
|
|
1510
|
+
const senderIds = [...new Set(candidates.map((post) => post.user_id))];
|
|
1511
|
+
let users = [];
|
|
1512
|
+
if (senderIds.length && isDangerousNameMatchingEnabled(account.config)) {
|
|
1513
|
+
users = await client.request("/users/ids", {
|
|
1514
|
+
method: "POST",
|
|
1515
|
+
body: JSON.stringify(senderIds),
|
|
1516
|
+
signal,
|
|
1517
|
+
timeoutMs: TIMEOUT_MS
|
|
1518
|
+
});
|
|
1519
|
+
signal.throwIfAborted();
|
|
1520
|
+
}
|
|
1521
|
+
const names = new Map(users.map((user) => [user.id, user.username ?? user.id]));
|
|
1522
|
+
let storeFailed = false;
|
|
1523
|
+
let storeRead;
|
|
1524
|
+
const readStoreAllowFrom = () => storeRead ??= monitor.pairing.readAllowFromStore().catch((error) => {
|
|
1525
|
+
storeFailed = true;
|
|
1526
|
+
throw error;
|
|
1527
|
+
});
|
|
1528
|
+
const allowed = new Map(await Promise.all(senderIds.map(async (senderId) => {
|
|
1529
|
+
try {
|
|
1530
|
+
signal.throwIfAborted();
|
|
1531
|
+
const access = await resolveMattermostMonitorInboundAccess({
|
|
1532
|
+
account,
|
|
1533
|
+
cfg,
|
|
1534
|
+
senderId,
|
|
1535
|
+
senderName: names.get(senderId) ?? senderId,
|
|
1536
|
+
channelId: turn.channelId,
|
|
1537
|
+
kind: turn.kind,
|
|
1538
|
+
groupPolicy: monitor.groupPolicy,
|
|
1539
|
+
readStoreAllowFrom,
|
|
1540
|
+
allowTextCommands: false,
|
|
1541
|
+
hasControlCommand: false,
|
|
1542
|
+
mayPair: false
|
|
1543
|
+
});
|
|
1544
|
+
signal.throwIfAborted();
|
|
1545
|
+
return [senderId, !storeFailed && shouldRetainMattermostSenderHistory({
|
|
1546
|
+
cfg,
|
|
1547
|
+
accountId: account.accountId,
|
|
1548
|
+
kind: turn.kind,
|
|
1549
|
+
ingress: access.ingress
|
|
1550
|
+
})];
|
|
1551
|
+
} catch {
|
|
1552
|
+
return [senderId, false];
|
|
1553
|
+
}
|
|
1554
|
+
})));
|
|
1555
|
+
signal.throwIfAborted();
|
|
1556
|
+
return candidates.filter((post) => allowed.get(post.user_id)).toSorted((a, b) => a.create_at - b.create_at || a.id.localeCompare(b.id)).map((post) => ({
|
|
1557
|
+
sender: names.get(post.user_id) ?? post.user_id,
|
|
1558
|
+
body: post.message?.trim() || "[attachment]",
|
|
1559
|
+
timestamp: post.create_at,
|
|
1560
|
+
messageId: post.id
|
|
1561
|
+
}));
|
|
1562
|
+
};
|
|
1563
|
+
return async (turn) => {
|
|
1564
|
+
if (historyLimit <= 0 || !Number.isFinite(turn.currentPostTimestamp) || turn.currentPostTimestamp <= 0) return { current: true };
|
|
1565
|
+
let identity;
|
|
1566
|
+
try {
|
|
1567
|
+
identity = readIdentity(turn);
|
|
1568
|
+
} catch {
|
|
1569
|
+
monitor.logVerboseMessage("mattermost: thread recovery skipped (session store unavailable)");
|
|
1570
|
+
return { current: true };
|
|
1571
|
+
}
|
|
1572
|
+
const previous = recoveries.get(turn.historyKey);
|
|
1573
|
+
let recovery = previous;
|
|
1574
|
+
if (!recovery || recovery.identity !== identity) {
|
|
1575
|
+
const adopting = previous?.identity === null && identity !== null;
|
|
1576
|
+
recovery = {
|
|
1577
|
+
identity,
|
|
1578
|
+
attempts: adopting ? previous.attempts : 0,
|
|
1579
|
+
nextAttemptAt: adopting ? previous.nextAttemptAt : 0,
|
|
1580
|
+
status: adopting && !previous.completion && previous.attempts > 0 ? previous.status : "pending"
|
|
1581
|
+
};
|
|
1582
|
+
if (!previous && (channelHistories.get(turn.historyKey)?.length ?? 0) > 0) recovery.status = "seeded";
|
|
1583
|
+
}
|
|
1584
|
+
touch(turn.historyKey, recovery);
|
|
1585
|
+
if (recovery.completion) {
|
|
1586
|
+
const history = await recovery.completion;
|
|
1587
|
+
return {
|
|
1588
|
+
current: owns(turn, recovery),
|
|
1589
|
+
history
|
|
1590
|
+
};
|
|
1591
|
+
}
|
|
1592
|
+
if (recovery.status === "settled") return { current: true };
|
|
1593
|
+
if (recovery.status === "seeded" && channelHistories.has(turn.historyKey)) return { current: true };
|
|
1594
|
+
if (recovery.attempts >= MAX_ATTEMPTS || Date.now() < recovery.nextAttemptAt || inFlight.size >= MAX_IN_FLIGHT) return { current: true };
|
|
1595
|
+
recovery.attempts++;
|
|
1596
|
+
recovery.nextAttemptAt = Date.now() + COOLDOWN_MS;
|
|
1597
|
+
const owner = recovery;
|
|
1598
|
+
const controller = new AbortController();
|
|
1599
|
+
const deadlineAt = performance.now() + TIMEOUT_MS;
|
|
1600
|
+
let timer;
|
|
1601
|
+
const deadline = new Promise((_, reject) => {
|
|
1602
|
+
timer = setTimeout(() => {
|
|
1603
|
+
const error = new DOMException("Mattermost thread recovery deadline", "TimeoutError");
|
|
1604
|
+
controller.abort(error);
|
|
1605
|
+
reject(error);
|
|
1606
|
+
}, TIMEOUT_MS);
|
|
1607
|
+
});
|
|
1608
|
+
const operation = fetchEntries(turn, controller.signal);
|
|
1609
|
+
inFlight.add(operation);
|
|
1610
|
+
operation.then(() => inFlight.delete(operation), () => inFlight.delete(operation));
|
|
1611
|
+
owner.completion = (async () => {
|
|
1612
|
+
try {
|
|
1613
|
+
const entries = await Promise.race([operation, deadline]);
|
|
1614
|
+
if (performance.now() >= deadlineAt) throw new DOMException("Mattermost thread recovery deadline", "TimeoutError");
|
|
1615
|
+
if (!owns(turn, owner)) return;
|
|
1616
|
+
const live = channelHistories.get(turn.historyKey) ?? [];
|
|
1617
|
+
const merged = /* @__PURE__ */ new Map();
|
|
1618
|
+
for (const entry of [...entries, ...live]) merged.set(entry.messageId ?? entry, entry);
|
|
1619
|
+
const snapshot = [...merged.values()].toSorted((a, b) => (a.timestamp ?? Infinity) - (b.timestamp ?? Infinity));
|
|
1620
|
+
const window = snapshot.slice(-historyLimit);
|
|
1621
|
+
if (window.length) {
|
|
1622
|
+
histories.clear({
|
|
1623
|
+
historyKey: turn.historyKey,
|
|
1624
|
+
limit: historyLimit
|
|
1625
|
+
});
|
|
1626
|
+
for (const entry of window) histories.record({
|
|
1627
|
+
historyKey: turn.historyKey,
|
|
1628
|
+
limit: historyLimit,
|
|
1629
|
+
entry
|
|
1630
|
+
});
|
|
1631
|
+
}
|
|
1632
|
+
owner.attempts = 0;
|
|
1633
|
+
owner.nextAttemptAt = 0;
|
|
1634
|
+
owner.status = window.length ? "seeded" : "settled";
|
|
1635
|
+
monitor.logVerboseMessage(`mattermost: thread recovery retained ${entries.length} entries historyKey=${turn.historyKey}`);
|
|
1636
|
+
return snapshot;
|
|
1637
|
+
} catch (error) {
|
|
1638
|
+
if (!owns(turn, owner)) return;
|
|
1639
|
+
owner.status = error instanceof Error && isRetryableError(error) && owner.attempts < MAX_ATTEMPTS ? "pending" : "settled";
|
|
1640
|
+
monitor.logVerboseMessage(`mattermost: thread recovery ${owner.status === "pending" ? "retry scheduled" : "gave up"} attempt=${owner.attempts}/${MAX_ATTEMPTS}`);
|
|
1641
|
+
return;
|
|
1642
|
+
} finally {
|
|
1643
|
+
clearTimeout(timer);
|
|
1644
|
+
owner.completion = void 0;
|
|
1645
|
+
}
|
|
1646
|
+
})();
|
|
1647
|
+
const history = await owner.completion;
|
|
1648
|
+
return {
|
|
1649
|
+
current: owns(turn, owner),
|
|
1650
|
+
history
|
|
1651
|
+
};
|
|
1652
|
+
};
|
|
1653
|
+
}
|
|
1654
|
+
//#endregion
|
|
1394
1655
|
//#region extensions/mattermost/src/mattermost/draft-stream.ts
|
|
1395
1656
|
const MATTERMOST_STREAM_MAX_CHARS = 4e3;
|
|
1396
1657
|
const DEFAULT_THROTTLE_MS = 1e3;
|
|
@@ -1439,9 +1700,6 @@ function createMattermostDraftStream(params) {
|
|
|
1439
1700
|
};
|
|
1440
1701
|
const sealedAssistantTexts = [];
|
|
1441
1702
|
const publishedAssistantParts = /* @__PURE__ */ new Map();
|
|
1442
|
-
const trackPublishedAssistantPart = (part) => {
|
|
1443
|
-
publishedAssistantParts.set(part.messageId, part);
|
|
1444
|
-
};
|
|
1445
1703
|
const sendOrEditStreamMessage = async (text) => {
|
|
1446
1704
|
if (streamState.stopped && !streamState.final) return false;
|
|
1447
1705
|
const target = currentGeneration;
|
|
@@ -1498,6 +1756,18 @@ function createMattermostDraftStream(params) {
|
|
|
1498
1756
|
const sealed = currentGeneration;
|
|
1499
1757
|
const assistantText = sealed.latestAssistantText?.trim();
|
|
1500
1758
|
let publishedAssistantOffset = 0;
|
|
1759
|
+
const recordPublishedAssistantPart = (messageId, content, offset) => {
|
|
1760
|
+
if (!assistantText) return;
|
|
1761
|
+
publishedAssistantParts.set(messageId, {
|
|
1762
|
+
messageId,
|
|
1763
|
+
content
|
|
1764
|
+
});
|
|
1765
|
+
publishedAssistantOffset = consumeMattermostPublishedChunk({
|
|
1766
|
+
source: assistantText,
|
|
1767
|
+
offset,
|
|
1768
|
+
chunk: content
|
|
1769
|
+
}) ?? offset;
|
|
1770
|
+
};
|
|
1501
1771
|
const boundary = (async () => {
|
|
1502
1772
|
try {
|
|
1503
1773
|
await sealed.ready;
|
|
@@ -1516,47 +1786,18 @@ function createMattermostDraftStream(params) {
|
|
|
1516
1786
|
if (sealed.postId) {
|
|
1517
1787
|
if (assistantText && (sealed.lastProviderText || sealed.lastSentText)) {
|
|
1518
1788
|
const publishedContent = sealed.lastProviderText ?? sealed.lastSentText;
|
|
1519
|
-
|
|
1520
|
-
messageId: sealed.postId,
|
|
1521
|
-
content: publishedContent
|
|
1522
|
-
});
|
|
1523
|
-
publishedAssistantOffset = consumeMattermostPublishedChunk({
|
|
1524
|
-
source: assistantText,
|
|
1525
|
-
offset: 0,
|
|
1526
|
-
chunk: publishedContent
|
|
1527
|
-
}) ?? 0;
|
|
1789
|
+
recordPublishedAssistantPart(sealed.postId, publishedContent, 0);
|
|
1528
1790
|
}
|
|
1529
1791
|
let providerFirstChunk = sealed.lastProviderText ?? firstChunk;
|
|
1530
1792
|
if (firstChunk !== sealed.lastSentText) providerFirstChunk = (await updateMattermostPost(params.client, sealed.postId, { message: firstChunk })).message ?? firstChunk;
|
|
1531
|
-
|
|
1532
|
-
trackPublishedAssistantPart({
|
|
1533
|
-
messageId: sealed.postId,
|
|
1534
|
-
content: providerFirstChunk
|
|
1535
|
-
});
|
|
1536
|
-
publishedAssistantOffset = consumeMattermostPublishedChunk({
|
|
1537
|
-
source: assistantText,
|
|
1538
|
-
offset: 0,
|
|
1539
|
-
chunk: providerFirstChunk
|
|
1540
|
-
}) ?? 0;
|
|
1541
|
-
}
|
|
1793
|
+
recordPublishedAssistantPart(sealed.postId, providerFirstChunk, 0);
|
|
1542
1794
|
} else {
|
|
1543
1795
|
const firstPost = await createMattermostPost(params.client, {
|
|
1544
1796
|
channelId: params.channelId,
|
|
1545
1797
|
message: firstChunk,
|
|
1546
1798
|
rootId: params.rootId
|
|
1547
1799
|
});
|
|
1548
|
-
|
|
1549
|
-
const publishedContent = firstPost.message ?? firstChunk;
|
|
1550
|
-
trackPublishedAssistantPart({
|
|
1551
|
-
messageId: firstPost.id,
|
|
1552
|
-
content: publishedContent
|
|
1553
|
-
});
|
|
1554
|
-
publishedAssistantOffset = consumeMattermostPublishedChunk({
|
|
1555
|
-
source: assistantText,
|
|
1556
|
-
offset: 0,
|
|
1557
|
-
chunk: publishedContent
|
|
1558
|
-
}) ?? 0;
|
|
1559
|
-
}
|
|
1800
|
+
recordPublishedAssistantPart(firstPost.id, firstPost.message ?? firstChunk, 0);
|
|
1560
1801
|
}
|
|
1561
1802
|
for (const chunk of chunks.slice(1)) {
|
|
1562
1803
|
const post = await createMattermostPost(params.client, {
|
|
@@ -1564,18 +1805,7 @@ function createMattermostDraftStream(params) {
|
|
|
1564
1805
|
message: chunk,
|
|
1565
1806
|
rootId: params.rootId
|
|
1566
1807
|
});
|
|
1567
|
-
|
|
1568
|
-
const publishedContent = post.message ?? chunk;
|
|
1569
|
-
trackPublishedAssistantPart({
|
|
1570
|
-
messageId: post.id,
|
|
1571
|
-
content: publishedContent
|
|
1572
|
-
});
|
|
1573
|
-
publishedAssistantOffset = consumeMattermostPublishedChunk({
|
|
1574
|
-
source: assistantText,
|
|
1575
|
-
offset: publishedAssistantOffset,
|
|
1576
|
-
chunk: publishedContent
|
|
1577
|
-
}) ?? publishedAssistantOffset;
|
|
1578
|
-
}
|
|
1808
|
+
recordPublishedAssistantPart(post.id, post.message ?? chunk, publishedAssistantOffset);
|
|
1579
1809
|
}
|
|
1580
1810
|
if (assistantText) sealedAssistantTexts.push({
|
|
1581
1811
|
text: assistantText,
|
|
@@ -1729,11 +1959,11 @@ function createMattermostDraftStream(params) {
|
|
|
1729
1959
|
}
|
|
1730
1960
|
//#endregion
|
|
1731
1961
|
//#region extensions/mattermost/src/mattermost/monitor-draft-delivery.ts
|
|
1732
|
-
function combineMattermostVisibleDeliveryResults(results) {
|
|
1962
|
+
function combineMattermostVisibleDeliveryResults(results, outcome) {
|
|
1733
1963
|
const visibleResults = results.filter((result) => result?.visibleReplySent === true);
|
|
1734
1964
|
if (visibleResults.length === 0) return;
|
|
1735
1965
|
return {
|
|
1736
|
-
outcome
|
|
1966
|
+
outcome,
|
|
1737
1967
|
...createAcceptedChannelDeliveryResult({
|
|
1738
1968
|
deliveryResults: visibleResults,
|
|
1739
1969
|
content: joinMattermostVisibleContent(visibleResults.map((result) => result.content))
|
|
@@ -1746,35 +1976,30 @@ async function deliverMattermostReplyWithDraftPreview(params) {
|
|
|
1746
1976
|
visibleReplySent: false,
|
|
1747
1977
|
suppression: { reason: "no_visible_result" }
|
|
1748
1978
|
};
|
|
1749
|
-
let
|
|
1750
|
-
|
|
1751
|
-
|
|
1752
|
-
|
|
1753
|
-
|
|
1754
|
-
let previewFinalTextAlreadyDelivered =
|
|
1755
|
-
|
|
1756
|
-
|
|
1757
|
-
|
|
1979
|
+
let outcome = "text";
|
|
1980
|
+
const ttsSupplement = getReplyPayloadTtsSupplement(params.payload);
|
|
1981
|
+
const previewFinalResolution = params.info.kind === "final" && !params.previewLifecycle.previewFinalized ? params.resolvePreviewFinalText(params.payload.text ?? ttsSupplement?.spokenText) : void 0;
|
|
1982
|
+
const confirmedPreviewDelivery = previewFinalResolution?.confirmedDelivery;
|
|
1983
|
+
const previewFinalDeliveryText = previewFinalResolution?.deliveryText;
|
|
1984
|
+
let previewFinalTextAlreadyDelivered = previewFinalResolution?.alreadyDelivered === true && params.payload.isError !== true;
|
|
1985
|
+
if (previewFinalTextAlreadyDelivered && !resolveSendableOutboundReplyParts(params.payload).hasMedia && !params.payload.presentation && confirmedPreviewDelivery?.visibleReplySent) try {
|
|
1986
|
+
await params.previewLifecycle.observeDelivery(confirmedPreviewDelivery);
|
|
1987
|
+
await params.recordThreadParticipation?.();
|
|
1988
|
+
return confirmedPreviewDelivery;
|
|
1989
|
+
} catch (error) {
|
|
1990
|
+
throw createChannelPartialDeliveryError(error, {
|
|
1991
|
+
...confirmedPreviewDelivery,
|
|
1992
|
+
visibleReplySent: true
|
|
1993
|
+
});
|
|
1994
|
+
}
|
|
1758
1995
|
try {
|
|
1759
|
-
|
|
1996
|
+
return combineMattermostVisibleDeliveryResults([confirmedPreviewDelivery, (await params.previewLifecycle.deliver({
|
|
1760
1997
|
kind: params.info.kind,
|
|
1761
1998
|
payload: params.payload,
|
|
1762
|
-
|
|
1763
|
-
|
|
1764
|
-
flush: params.draftStream.flush,
|
|
1765
|
-
clear: params.draftStream.clear,
|
|
1766
|
-
discardPending: params.draftStream.discardPending,
|
|
1767
|
-
seal: params.draftStream.seal,
|
|
1768
|
-
id: params.draftStream.postId
|
|
1769
|
-
} },
|
|
1999
|
+
isError: params.payload.isError,
|
|
2000
|
+
adapter: {
|
|
1770
2001
|
buildFinalEdit: (payload) => {
|
|
1771
2002
|
const hasMedia = Boolean(payload.mediaUrl) || (payload.mediaUrls?.length ?? 0) > 0;
|
|
1772
|
-
const ttsSupplement = getReplyPayloadTtsSupplement(payload);
|
|
1773
|
-
const previewFinalResolution = params.resolvePreviewFinalText(payload.text ?? ttsSupplement?.spokenText);
|
|
1774
|
-
confirmedPreviewDelivery = previewFinalResolution?.confirmedDelivery;
|
|
1775
|
-
previewFinalDeliveryText = previewFinalResolution?.deliveryText;
|
|
1776
|
-
previewFinalTextAlreadyDelivered = previewFinalResolution?.alreadyDelivered === true && payload.isError !== true;
|
|
1777
|
-
useConfirmedPreviewAsWholeFinal = previewFinalTextAlreadyDelivered && !resolveSendableOutboundReplyParts(payload).hasMedia && !payload.presentation;
|
|
1778
2003
|
const previewFinalText = previewFinalResolution?.editText;
|
|
1779
2004
|
if (hasMedia && !ttsSupplement || typeof previewFinalText !== "string" || payload.isError || payload.presentation || !canFinalizeMattermostPreviewInPlace({
|
|
1780
2005
|
kind: params.kind,
|
|
@@ -1782,36 +2007,33 @@ async function deliverMattermostReplyWithDraftPreview(params) {
|
|
|
1782
2007
|
threadRootId: params.effectiveReplyToId,
|
|
1783
2008
|
replyToId: payload.replyToId
|
|
1784
2009
|
})) return;
|
|
1785
|
-
pendingPreviewFinalContent = previewFinalText;
|
|
1786
2010
|
return { message: previewFinalText };
|
|
1787
2011
|
},
|
|
1788
2012
|
editFinal: async (previewPostId, edit) => {
|
|
1789
|
-
|
|
1790
|
-
|
|
1791
|
-
|
|
1792
|
-
|
|
1793
|
-
params.previewState.finalizedViaPreviewPost = true;
|
|
1794
|
-
previewFinalTextAlreadyDelivered = true;
|
|
1795
|
-
previewDeliveryResult = {
|
|
1796
|
-
outcome: "text",
|
|
1797
|
-
messageIds: listMessageReceiptPlatformIds(receipt),
|
|
2013
|
+
const post = await updateMattermostPost(params.client, previewPostId, edit);
|
|
2014
|
+
const receipt = createPreviewMessageReceipt({ id: post.id ?? previewPostId });
|
|
2015
|
+
return {
|
|
2016
|
+
messageIds: receipt.platformMessageIds,
|
|
1798
2017
|
receipt,
|
|
1799
2018
|
visibleReplySent: true,
|
|
1800
|
-
content:
|
|
2019
|
+
content: post.message ?? edit.message
|
|
1801
2020
|
};
|
|
1802
|
-
|
|
2021
|
+
},
|
|
2022
|
+
onPreviewFinalized: async () => {
|
|
2023
|
+
previewFinalTextAlreadyDelivered = true;
|
|
2024
|
+
await params.recordThreadParticipation?.();
|
|
1803
2025
|
},
|
|
1804
2026
|
buildSupplementalPayload: (payload) => getReplyPayloadTtsSupplement(payload) ? buildTtsSupplementMediaPayload(payload) : void 0,
|
|
1805
2027
|
deliverSupplemental: async (payload) => {
|
|
1806
|
-
|
|
1807
|
-
|
|
2028
|
+
const delivered = await params.deliverPayload(payload);
|
|
2029
|
+
if (delivered.outcome === "media") outcome = "media";
|
|
2030
|
+
return delivered.visibleReplySent ? delivered : false;
|
|
1808
2031
|
},
|
|
1809
2032
|
logPreviewEditFailure: (err) => {
|
|
1810
2033
|
params.logVerboseMessage(`mattermost preview final edit failed; falling back to normal send (${String(err)})`);
|
|
1811
2034
|
}
|
|
1812
|
-
}
|
|
2035
|
+
},
|
|
1813
2036
|
deliverNormally: async (payload) => {
|
|
1814
|
-
if (useConfirmedPreviewAsWholeFinal && confirmedPreviewDelivery?.visibleReplySent === true) return true;
|
|
1815
2037
|
const supplement = getReplyPayloadTtsSupplement(payload);
|
|
1816
2038
|
const resolvedDeliveryText = previewFinalDeliveryText ?? (previewFinalTextAlreadyDelivered ? "" : void 0);
|
|
1817
2039
|
const payloadText = payload.text?.trim();
|
|
@@ -1822,38 +2044,22 @@ async function deliverMattermostReplyWithDraftPreview(params) {
|
|
|
1822
2044
|
...payload,
|
|
1823
2045
|
text: resolvedDeliveryText
|
|
1824
2046
|
} : payload;
|
|
1825
|
-
|
|
1826
|
-
|
|
1827
|
-
|
|
1828
|
-
|
|
2047
|
+
const delivered = await params.deliverPayload(deliveryPayload);
|
|
2048
|
+
if (delivered.outcome === "media") outcome = "media";
|
|
2049
|
+
return delivered;
|
|
2050
|
+
},
|
|
2051
|
+
onNormalDelivered: params.recordThreadParticipation
|
|
2052
|
+
})).deliveryResult], outcome) ?? {
|
|
1829
2053
|
outcome: "empty",
|
|
1830
2054
|
visibleReplySent: false,
|
|
1831
2055
|
suppression: { reason: "no_visible_result" }
|
|
1832
2056
|
};
|
|
1833
|
-
return combineMattermostVisibleDeliveryResults([
|
|
1834
|
-
confirmedPreviewDelivery,
|
|
1835
|
-
previewDeliveryResult,
|
|
1836
|
-
supplementalDeliveryResult,
|
|
1837
|
-
normalDeliveryResult
|
|
1838
|
-
]) ?? previewDeliveryResult;
|
|
1839
2057
|
} catch (error) {
|
|
1840
|
-
|
|
1841
|
-
confirmedPreviewDelivery,
|
|
1842
|
-
previewDeliveryResult,
|
|
1843
|
-
normalDeliveryResult,
|
|
1844
|
-
supplementalDeliveryResult
|
|
1845
|
-
].filter((result) => result?.visibleReplySent === true);
|
|
1846
|
-
if (completedVisibleResults.length === 0) throw error;
|
|
2058
|
+
if (!confirmedPreviewDelivery?.visibleReplySent) throw error;
|
|
1847
2059
|
const failedPartial = isChannelPartialDeliveryError(error) ? error.deliveryResult : void 0;
|
|
1848
2060
|
throw createChannelPartialDeliveryError(error, createAcceptedChannelDeliveryResult({
|
|
1849
|
-
deliveryResults: [
|
|
1850
|
-
content: joinMattermostVisibleContent([
|
|
1851
|
-
confirmedPreviewDelivery?.content,
|
|
1852
|
-
previewDeliveryResult?.content,
|
|
1853
|
-
normalDeliveryResult?.content,
|
|
1854
|
-
supplementalDeliveryResult?.content,
|
|
1855
|
-
failedPartial?.content
|
|
1856
|
-
])
|
|
2061
|
+
deliveryResults: [confirmedPreviewDelivery, ...failedPartial ? [failedPartial] : []],
|
|
2062
|
+
content: joinMattermostVisibleContent([confirmedPreviewDelivery.content, failedPartial?.content])
|
|
1857
2063
|
}));
|
|
1858
2064
|
}
|
|
1859
2065
|
}
|
|
@@ -1874,9 +2080,9 @@ const threadParticipation = createPersistentDedupeCache({
|
|
|
1874
2080
|
function makeKey(accountId, channelId, threadRootId) {
|
|
1875
2081
|
return `${accountId}:${channelId}:${threadRootId}`;
|
|
1876
2082
|
}
|
|
1877
|
-
function recordMattermostThreadParticipation(accountId, channelId, threadRootId, opts) {
|
|
2083
|
+
async function recordMattermostThreadParticipation(accountId, channelId, threadRootId, opts) {
|
|
1878
2084
|
if (!accountId || !channelId || !threadRootId) return;
|
|
1879
|
-
threadParticipation.register(makeKey(accountId, channelId, threadRootId), {
|
|
2085
|
+
await threadParticipation.register(makeKey(accountId, channelId, threadRootId), {
|
|
1880
2086
|
...opts?.agentId ? { agentId: opts.agentId } : {},
|
|
1881
2087
|
repliedAt: Date.now()
|
|
1882
2088
|
});
|
|
@@ -1948,6 +2154,7 @@ async function dispatchMattermostInboundTurn(monitor, params) {
|
|
|
1948
2154
|
let blockPreviewActivity = "none";
|
|
1949
2155
|
let blockPreviewAssistantMessagePending = false;
|
|
1950
2156
|
const progressDraft = createChannelProgressDraftCompositor({
|
|
2157
|
+
preparedItems: true,
|
|
1951
2158
|
entry: account.config,
|
|
1952
2159
|
mode: account.streamingMode,
|
|
1953
2160
|
active: draftPreviewEnabled,
|
|
@@ -1971,7 +2178,18 @@ async function dispatchMattermostInboundTurn(monitor, params) {
|
|
|
1971
2178
|
if (activity === "tool") lastPartialText = "";
|
|
1972
2179
|
return boundarySettled;
|
|
1973
2180
|
};
|
|
1974
|
-
const
|
|
2181
|
+
const previewLifecycle = createLivePreviewLifecycle({
|
|
2182
|
+
draft: draftPreviewEnabled ? {
|
|
2183
|
+
flush: draftStream.flush,
|
|
2184
|
+
id: draftStream.postId,
|
|
2185
|
+
seal: draftStream.seal,
|
|
2186
|
+
discardPending: draftStream.discardPending,
|
|
2187
|
+
clear: draftStream.clear
|
|
2188
|
+
} : void 0,
|
|
2189
|
+
onFinalStarted: () => progressDraft.markFinalReplyStarted(),
|
|
2190
|
+
onFinalDelivered: () => progressDraft.markFinalReplyDelivered(),
|
|
2191
|
+
onCleanupFailure: (err) => monitor.logVerboseMessage(`mattermost draft preview cleanup failed: ${String(err)}`)
|
|
2192
|
+
});
|
|
1975
2193
|
const resolvePreviewFinalText = (text) => {
|
|
1976
2194
|
const resolution = draftStream.resolveFinalText(typeof text === "string" ? text : "");
|
|
1977
2195
|
const confirmedDelivery = resolution.publishedParts.length > 0 ? (() => {
|
|
@@ -2047,13 +2265,12 @@ async function dispatchMattermostInboundTurn(monitor, params) {
|
|
|
2047
2265
|
if (info.kind === "final") {
|
|
2048
2266
|
await enterBlockPreviewActivity("text");
|
|
2049
2267
|
await draftStream.settleBoundaries();
|
|
2050
|
-
progressDraft.markFinalReplyStarted();
|
|
2051
2268
|
}
|
|
2052
2269
|
let threadParticipationRecorded = false;
|
|
2053
|
-
const markThreadParticipation = () => {
|
|
2270
|
+
const markThreadParticipation = async () => {
|
|
2054
2271
|
if (!threadParticipationRecorded && kind !== "direct" && effectiveReplyToId) {
|
|
2055
2272
|
threadParticipationRecorded = true;
|
|
2056
|
-
recordMattermostThreadParticipation(account.accountId, channelId, effectiveReplyToId, { agentId: route.agentId });
|
|
2273
|
+
await recordMattermostThreadParticipation(account.accountId, channelId, effectiveReplyToId, { agentId: route.agentId });
|
|
2057
2274
|
}
|
|
2058
2275
|
};
|
|
2059
2276
|
const result = await deliverMattermostReplyWithDraftPreview({
|
|
@@ -2061,10 +2278,9 @@ async function dispatchMattermostInboundTurn(monitor, params) {
|
|
|
2061
2278
|
info,
|
|
2062
2279
|
kind,
|
|
2063
2280
|
client,
|
|
2064
|
-
|
|
2281
|
+
previewLifecycle,
|
|
2065
2282
|
effectiveReplyToId,
|
|
2066
2283
|
resolvePreviewFinalText,
|
|
2067
|
-
previewState,
|
|
2068
2284
|
logVerboseMessage: monitor.logVerboseMessage,
|
|
2069
2285
|
recordThreadParticipation: markThreadParticipation,
|
|
2070
2286
|
deliverPayload: async (payloadToDeliver) => {
|
|
@@ -2088,12 +2304,7 @@ async function dispatchMattermostInboundTurn(monitor, params) {
|
|
|
2088
2304
|
textLimit,
|
|
2089
2305
|
tableMode,
|
|
2090
2306
|
sendMessage: sendMessageMattermost
|
|
2091
|
-
}).catch((error) => {
|
|
2092
|
-
if (isChannelPartialDeliveryError(error)) markThreadParticipation();
|
|
2093
|
-
throw error;
|
|
2094
2307
|
});
|
|
2095
|
-
if (deliveryResult.outcome === "text" || deliveryResult.outcome === "media") markThreadParticipation();
|
|
2096
|
-
else if (deliveryResult.outcome === "empty" && finalTextResolution?.kind === "already-delivered") markThreadParticipation();
|
|
2097
2308
|
const deliveryLog = formatMattermostFinalDeliveryOutcomeLog({
|
|
2098
2309
|
outcome: deliveryResult.outcome,
|
|
2099
2310
|
payload: resolvedPayload,
|
|
@@ -2104,15 +2315,11 @@ async function dispatchMattermostInboundTurn(monitor, params) {
|
|
|
2104
2315
|
if (deliveryLog) runtime.log?.(deliveryLog);
|
|
2105
2316
|
return deliveryResult;
|
|
2106
2317
|
}
|
|
2107
|
-
}).catch((error) => {
|
|
2108
|
-
if (isChannelPartialDeliveryError(error))
|
|
2109
|
-
markThreadParticipation();
|
|
2110
|
-
if (info.kind === "final") progressDraft.markFinalReplyDelivered();
|
|
2111
|
-
}
|
|
2318
|
+
}).catch(async (error) => {
|
|
2319
|
+
if (isChannelPartialDeliveryError(error)) await markThreadParticipation();
|
|
2112
2320
|
throw error;
|
|
2113
2321
|
});
|
|
2114
|
-
if (result.visibleReplySent) markThreadParticipation();
|
|
2115
|
-
if (info.kind === "final") progressDraft.markFinalReplyDelivered();
|
|
2322
|
+
if (result.visibleReplySent) await markThreadParticipation();
|
|
2116
2323
|
return result;
|
|
2117
2324
|
},
|
|
2118
2325
|
onError: (err, info) => {
|
|
@@ -2174,10 +2381,12 @@ async function dispatchMattermostInboundTurn(monitor, params) {
|
|
|
2174
2381
|
dispatcherOptions,
|
|
2175
2382
|
delivery,
|
|
2176
2383
|
replyOptions: {
|
|
2384
|
+
progressPreambleEnabled: draftProgressEnabled,
|
|
2385
|
+
commentaryProgressEnabled: progressDraft.commentaryProgressEnabled,
|
|
2177
2386
|
...turnAdoptionLifecycle ? bindIngressLifecycleToReplyOptions(turnAdoptionLifecycle) : {},
|
|
2178
2387
|
allowProgressCallbacksWhenSourceDeliverySuppressed: draftProgressEnabled ? true : void 0,
|
|
2179
2388
|
preserveProgressCallbackStartOrder: draftPreviewEnabled ? true : void 0,
|
|
2180
|
-
onObservedReplyDelivery:
|
|
2389
|
+
onObservedReplyDelivery: draftPreviewEnabled ? () => previewLifecycle.observeDelivery({ visibleReplySent: true }) : void 0,
|
|
2181
2390
|
disableBlockStreaming: draftPreviewEnabled ? true : replyOptions.disableBlockStreaming,
|
|
2182
2391
|
...suppressDefaultToolProgressMessages ? { suppressDefaultToolProgressMessages: true } : {},
|
|
2183
2392
|
onModelSelected,
|
|
@@ -2209,28 +2418,18 @@ async function dispatchMattermostInboundTurn(monitor, params) {
|
|
|
2209
2418
|
onPlanUpdate: async (payloadValue) => {
|
|
2210
2419
|
if (!draftProgressEnabled || payloadValue.phase !== "update") return false;
|
|
2211
2420
|
const boundarySettled = enterBlockPreviewActivity("tool");
|
|
2212
|
-
const progressSettled = progressDraft.pushPlanProgress(payloadValue.steps, {
|
|
2213
|
-
|
|
2214
|
-
|
|
2215
|
-
|
|
2216
|
-
},
|
|
2217
|
-
onToolStart: async (payloadValue) => {
|
|
2218
|
-
if (!draftProgressEnabled) return false;
|
|
2219
|
-
const boundarySettled = enterBlockPreviewActivity("tool");
|
|
2220
|
-
const progressSettled = progressDraft.pushToolProgress(buildChannelProgressDraftLineForEntry(account.config, {
|
|
2221
|
-
event: "tool",
|
|
2222
|
-
itemId: payloadValue.itemId,
|
|
2223
|
-
toolCallId: payloadValue.toolCallId,
|
|
2224
|
-
name: payloadValue.name,
|
|
2225
|
-
phase: payloadValue.phase,
|
|
2226
|
-
args: payloadValue.args
|
|
2227
|
-
}, payloadValue.detailMode ? { detailMode: payloadValue.detailMode } : void 0), { startImmediately: true });
|
|
2421
|
+
const progressSettled = progressDraft.pushPlanProgress(payloadValue.steps, {
|
|
2422
|
+
explanation: payloadValue.explanation,
|
|
2423
|
+
explanationFormat: payloadValue.explanationFormat
|
|
2424
|
+
});
|
|
2228
2425
|
previewBoundaryController.noteUpdate();
|
|
2229
2426
|
const [, visible] = await Promise.all([boundarySettled, progressSettled]);
|
|
2230
2427
|
return visible;
|
|
2231
2428
|
},
|
|
2429
|
+
onToolStart: (payload) => progressDraft.pushToolEvent(payload),
|
|
2232
2430
|
onItemEvent: async (payloadLocal) => {
|
|
2233
2431
|
if (!draftProgressEnabled) return false;
|
|
2432
|
+
if (payloadLocal.hideFromChannelProgress || payloadLocal.suppressChannelProgress) return progressDraft.pushItemEvent(payloadLocal);
|
|
2234
2433
|
const boundarySettled = enterBlockPreviewActivity("tool");
|
|
2235
2434
|
const progressSettled = progressDraft.pushItemEvent(payloadLocal);
|
|
2236
2435
|
previewBoundaryController.noteUpdate();
|
|
@@ -2244,6 +2443,7 @@ async function dispatchMattermostInboundTurn(monitor, params) {
|
|
|
2244
2443
|
} finally {
|
|
2245
2444
|
try {
|
|
2246
2445
|
await draftStream.stop();
|
|
2446
|
+
await previewLifecycle.cleanup();
|
|
2247
2447
|
} catch (err) {
|
|
2248
2448
|
monitor.logVerboseMessage(`mattermost draft preview cleanup failed: ${String(err)}`);
|
|
2249
2449
|
}
|
|
@@ -2261,7 +2461,12 @@ function createMattermostPostHandler(monitor) {
|
|
|
2261
2461
|
});
|
|
2262
2462
|
const { resolveMattermostMedia, resolveUserInfo } = resources;
|
|
2263
2463
|
const channelHistories = /* @__PURE__ */ new Map();
|
|
2264
|
-
const historyLimit =
|
|
2464
|
+
const historyLimit = resolvePromptHistoryLimit(account.config.historyLimit ?? cfg.messages?.groupChat?.historyLimit, DEFAULT_GROUP_HISTORY_LIMIT);
|
|
2465
|
+
const recoverThread = createMattermostThreadBackfill({
|
|
2466
|
+
monitor,
|
|
2467
|
+
channelHistories,
|
|
2468
|
+
historyLimit
|
|
2469
|
+
});
|
|
2265
2470
|
return async (post, payload, turnAdoptionLifecycle, messageIds) => {
|
|
2266
2471
|
const channelId = post.channel_id ?? payload.data?.channel_id ?? payload.broadcast?.channel_id;
|
|
2267
2472
|
if (!channelId) {
|
|
@@ -2307,7 +2512,8 @@ function createMattermostPostHandler(monitor) {
|
|
|
2307
2512
|
});
|
|
2308
2513
|
const historyKey = resolveMattermostPendingHistoryKey({
|
|
2309
2514
|
kind,
|
|
2310
|
-
sessionKey
|
|
2515
|
+
sessionKey,
|
|
2516
|
+
threadRootId: effectiveReplyToId
|
|
2311
2517
|
});
|
|
2312
2518
|
const fileIds = uniqueStrings(normalizeTrimmedStringList(post.file_ids ?? []));
|
|
2313
2519
|
const nativeMedia = fileIds.map(() => ({}));
|
|
@@ -2391,14 +2597,11 @@ function createMattermostPostHandler(monitor) {
|
|
|
2391
2597
|
return;
|
|
2392
2598
|
}
|
|
2393
2599
|
if (accessDecision.ingress.reasonCode === "group_policy_not_allowlisted") {
|
|
2394
|
-
if (
|
|
2395
|
-
|
|
2396
|
-
|
|
2397
|
-
|
|
2398
|
-
|
|
2399
|
-
}),
|
|
2400
|
-
kind: "history",
|
|
2401
|
-
senderAllowed: false
|
|
2600
|
+
if (shouldRetainMattermostSenderHistory({
|
|
2601
|
+
cfg,
|
|
2602
|
+
accountId: account.accountId,
|
|
2603
|
+
kind,
|
|
2604
|
+
ingress: accessDecision.ingress
|
|
2402
2605
|
})) recordPendingHistory();
|
|
2403
2606
|
monitor.logVerboseMessage(`mattermost: drop group sender=${senderId} (not in groupAllowFrom)`);
|
|
2404
2607
|
return;
|
|
@@ -2496,7 +2699,7 @@ function createMattermostPostHandler(monitor) {
|
|
|
2496
2699
|
directId: senderId
|
|
2497
2700
|
});
|
|
2498
2701
|
const textWithId = `${bodyText}\n[mattermost message id: ${post.id} channel: ${channelId}]`;
|
|
2499
|
-
|
|
2702
|
+
const body = formatInboundEnvelope({
|
|
2500
2703
|
channel: "Mattermost",
|
|
2501
2704
|
from: fromLabel,
|
|
2502
2705
|
timestamp: typeof post.create_at === "number" ? post.create_at : void 0,
|
|
@@ -2509,7 +2712,22 @@ function createMattermostPostHandler(monitor) {
|
|
|
2509
2712
|
previousTimestamp,
|
|
2510
2713
|
envelope: envelopeOptions
|
|
2511
2714
|
});
|
|
2512
|
-
|
|
2715
|
+
const backfill = historyKey && effectiveReplyToId ? await recoverThread({
|
|
2716
|
+
historyKey,
|
|
2717
|
+
threadRootId: effectiveReplyToId,
|
|
2718
|
+
currentPostId: post.id,
|
|
2719
|
+
currentPostTimestamp: post.create_at ?? 0,
|
|
2720
|
+
agentId: route.agentId,
|
|
2721
|
+
channelId,
|
|
2722
|
+
kind
|
|
2723
|
+
}) : void 0;
|
|
2724
|
+
if (backfill && !backfill.current) {
|
|
2725
|
+
monitor.logVerboseMessage("mattermost: drop stale thread turn after session rotation");
|
|
2726
|
+
return;
|
|
2727
|
+
}
|
|
2728
|
+
const turnHistories = new Map(historyKey ? [[historyKey, (backfill?.history ?? channelHistories.get(historyKey) ?? []).filter((entry) => !allMessageIds.includes(entry.messageId ?? "") && (entry.timestamp === void 0 || post.create_at == null || entry.timestamp <= post.create_at)).slice(-historyLimit)]] : []);
|
|
2729
|
+
let combinedBody = body;
|
|
2730
|
+
if (historyKey) combinedBody = createChannelHistoryWindow({ historyMap: turnHistories }).buildPendingContext({
|
|
2513
2731
|
historyKey,
|
|
2514
2732
|
limit: historyLimit,
|
|
2515
2733
|
currentMessage: combinedBody,
|
|
@@ -2523,7 +2741,7 @@ function createMattermostPostHandler(monitor) {
|
|
|
2523
2741
|
envelope: envelopeOptions
|
|
2524
2742
|
})
|
|
2525
2743
|
});
|
|
2526
|
-
const inboundHistory = historyKey && historyLimit > 0 ? createChannelHistoryWindow({ historyMap:
|
|
2744
|
+
const inboundHistory = historyKey && historyLimit > 0 ? createChannelHistoryWindow({ historyMap: turnHistories }).buildInboundHistory({
|
|
2527
2745
|
historyKey,
|
|
2528
2746
|
limit: historyLimit
|
|
2529
2747
|
}) : void 0;
|
|
@@ -3076,11 +3294,12 @@ async function probeMattermost(baseUrl, botToken, timeoutMs = 2500, allowPrivate
|
|
|
3076
3294
|
error: "baseUrl missing"
|
|
3077
3295
|
};
|
|
3078
3296
|
const url = `${normalized}/api/v4/users/me`;
|
|
3297
|
+
const headers = { Authorization: `Bearer ${botToken}` };
|
|
3079
3298
|
return await runChannelProbe(void 0, async ({ elapsedMs }) => {
|
|
3080
3299
|
const resolvedTimeoutMs = timeoutMs > 0 ? resolveTimerTimeoutMs(timeoutMs, 2500) : void 0;
|
|
3081
3300
|
const { response: res, release } = await fetchWithSsrFGuard({
|
|
3082
3301
|
url,
|
|
3083
|
-
init: { headers
|
|
3302
|
+
init: { headers },
|
|
3084
3303
|
auditContext: "mattermost-probe",
|
|
3085
3304
|
policy: ssrfPolicyFromPrivateNetworkOptIn(allowPrivateNetwork),
|
|
3086
3305
|
...resolvedTimeoutMs !== void 0 ? { timeoutMs: resolvedTimeoutMs } : {},
|
|
@@ -3090,7 +3309,7 @@ async function probeMattermost(baseUrl, botToken, timeoutMs = 2500, allowPrivate
|
|
|
3090
3309
|
const requestElapsedMs = elapsedMs();
|
|
3091
3310
|
try {
|
|
3092
3311
|
if (!res.ok) {
|
|
3093
|
-
const detail = await readMattermostError(res);
|
|
3312
|
+
const detail = await readMattermostError(res, headers);
|
|
3094
3313
|
return {
|
|
3095
3314
|
ok: false,
|
|
3096
3315
|
status: res.status,
|