@openclaw/mattermost 2026.9.5 → 2026.9.7
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/icon.png +0 -0
- package/dist/.setup/{channel-plugin-api-N-mnrhds.mjs → channel-plugin-api-Bc8Qc1-t.mjs} +2 -2
- package/dist/.setup/{channel-plugin-api-CKz3b0dp.mjs → channel-plugin-api-DXqHarCt.mjs} +2 -2
- package/dist/.setup/{channel-plugin-runtime-Ca4cZHq2.mjs → channel-plugin-runtime-B0CAMiHe.mjs} +146 -176
- package/dist/.setup/channel.runtime-E2B5dNrh.mjs +383 -0
- package/dist/.setup/{client-Cx71KZ1x.mjs → client-CVeeTqCO.mjs} +55 -46
- package/dist/.setup/doctor-contract-BI6SB2cd.mjs +175 -0
- package/dist/.setup/{interactions-BG-CQbVD.mjs → interactions-DMSZYnEx.mjs} +170 -80
- package/dist/.setup/{channel.runtime-C074p7wv.mjs → monitor-BZyzPkkb.mjs} +237 -726
- package/dist/.setup/{monitor-auth-DBoM2Bja.mjs → monitor-auth-aZ0b1gqx.mjs} +11 -16
- package/dist/.setup/{normalize-BQzx2u8S.mjs → normalize-BCjtmxtp.mjs} +8 -17
- package/dist/.setup/rolldown-runtime-BBjsoOtd.mjs +27 -0
- package/dist/.setup/send-ClgX-usq.mjs +438 -0
- package/dist/.setup/{slash-state-CmyIYDIc.mjs → slash-state-Dni1XNc1.mjs} +144 -764
- package/dist/api.js +2 -2
- package/dist/channel-plugin-api.js +2 -2
- package/dist/channel-plugin-runtime.js +1 -1
- package/dist/doctor-contract-api.js +1 -1
- package/dist/policy-api.js +1 -1
- package/dist/runtime-api.js +2 -23
- package/dist/setup-entry.js +1 -1
- package/dist/slash-route-api.js +1 -1
- package/node_modules/zod/README.md +2 -2
- package/node_modules/zod/compile.cjs +19 -0
- package/node_modules/zod/index.cjs +19 -0
- package/node_modules/zod/locales/index.cjs +19 -0
- package/node_modules/zod/mini/index.cjs +19 -0
- package/node_modules/zod/package.json +8 -7
- package/node_modules/zod/src/v3/helpers/errorUtil.ts +1 -1
- package/node_modules/zod/src/v4/classic/external.ts +2 -0
- package/node_modules/zod/src/v4/classic/from-json-schema.ts +248 -25
- package/node_modules/zod/src/v4/classic/schemas.ts +243 -168
- package/node_modules/zod/src/v4/classic/tests/assignability.test.ts +60 -9
- package/node_modules/zod/src/v4/classic/tests/bigint.test.ts +6 -0
- package/node_modules/zod/src/v4/classic/tests/continuability.test.ts +2 -2
- package/node_modules/zod/src/v4/classic/tests/cyclic-data.test.ts +265 -0
- package/node_modules/zod/src/v4/classic/tests/discriminated-unions.test.ts +112 -6
- package/node_modules/zod/src/v4/classic/tests/enum.test.ts +9 -0
- package/node_modules/zod/src/v4/classic/tests/error.test.ts +130 -1
- package/node_modules/zod/src/v4/classic/tests/from-json-schema.test.ts +157 -0
- package/node_modules/zod/src/v4/classic/tests/iban.test.ts +81 -0
- package/node_modules/zod/src/v4/classic/tests/instance-footprint.test.ts +40 -2
- package/node_modules/zod/src/v4/classic/tests/instanceof.test.ts +27 -7
- package/node_modules/zod/src/v4/classic/tests/issue-schema.test.ts +88 -56
- package/node_modules/zod/src/v4/classic/tests/number.test.ts +39 -0
- package/node_modules/zod/src/v4/classic/tests/object.test.ts +56 -0
- package/node_modules/zod/src/v4/classic/tests/optin-ladder.test.ts +3 -2
- package/node_modules/zod/src/v4/classic/tests/prefault.test.ts +70 -0
- package/node_modules/zod/src/v4/classic/tests/properties.test.ts +141 -0
- package/node_modules/zod/src/v4/classic/tests/recursive-types.test.ts +46 -1
- 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 +95 -1
- package/node_modules/zod/src/v4/classic/tests/template-literal.test.ts +33 -1
- package/node_modules/zod/src/v4/classic/tests/to-json-schema.test.ts +234 -38
- package/node_modules/zod/src/v4/classic/tests/validate.test.ts +569 -0
- package/node_modules/zod/src/v4/core/api.ts +44 -28
- package/node_modules/zod/src/v4/core/checks.ts +62 -102
- package/node_modules/zod/src/v4/core/compile.ts +218 -93
- package/node_modules/zod/src/v4/core/core.ts +1 -3
- package/node_modules/zod/src/v4/core/doc.ts +6 -2
- package/node_modules/zod/src/v4/core/errors.ts +3 -6
- package/node_modules/zod/src/v4/core/json-schema-generator.ts +2 -2
- package/node_modules/zod/src/v4/core/json-schema-processors.ts +185 -81
- package/node_modules/zod/src/v4/core/memoizer.ts +75 -28
- package/node_modules/zod/src/v4/core/parse.ts +37 -16
- package/node_modules/zod/src/v4/core/regexes.ts +14 -4
- package/node_modules/zod/src/v4/core/schemas.ts +296 -132
- 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 +35 -0
- package/node_modules/zod/src/v4/core/tests/compile-generative.test.ts +445 -0
- package/node_modules/zod/src/v4/core/tests/compile.test.ts +399 -2
- package/node_modules/zod/src/v4/core/tests/email-regex.test.ts +140 -0
- package/node_modules/zod/src/v4/core/tests/locales/tg.test.ts +85 -0
- package/node_modules/zod/src/v4/core/tests/polyfill-collision.test.ts +46 -0
- package/node_modules/zod/src/v4/core/tests/url-no-canparse.test.ts +118 -16
- package/node_modules/zod/src/v4/core/to-json-schema.ts +9 -7
- package/node_modules/zod/src/v4/core/util.ts +218 -147
- package/node_modules/zod/src/v4/core/versions.ts +2 -2
- package/node_modules/zod/src/v4/locales/ar.ts +2 -0
- package/node_modules/zod/src/v4/locales/az.ts +2 -0
- package/node_modules/zod/src/v4/locales/be.ts +2 -0
- package/node_modules/zod/src/v4/locales/bg.ts +2 -0
- package/node_modules/zod/src/v4/locales/bn.ts +2 -0
- package/node_modules/zod/src/v4/locales/ca.ts +2 -0
- package/node_modules/zod/src/v4/locales/ckb.ts +2 -0
- package/node_modules/zod/src/v4/locales/cs.ts +2 -0
- package/node_modules/zod/src/v4/locales/da.ts +2 -0
- package/node_modules/zod/src/v4/locales/de.ts +2 -0
- package/node_modules/zod/src/v4/locales/el.ts +2 -0
- package/node_modules/zod/src/v4/locales/en.ts +2 -0
- package/node_modules/zod/src/v4/locales/eo.ts +2 -0
- package/node_modules/zod/src/v4/locales/es.ts +2 -0
- package/node_modules/zod/src/v4/locales/fa.ts +2 -0
- package/node_modules/zod/src/v4/locales/fi.ts +2 -0
- package/node_modules/zod/src/v4/locales/fr-CA.ts +2 -0
- package/node_modules/zod/src/v4/locales/fr.ts +2 -0
- package/node_modules/zod/src/v4/locales/gu.ts +2 -0
- package/node_modules/zod/src/v4/locales/he.ts +2 -0
- package/node_modules/zod/src/v4/locales/hi.ts +2 -0
- package/node_modules/zod/src/v4/locales/hr.ts +2 -0
- package/node_modules/zod/src/v4/locales/hu.ts +2 -0
- package/node_modules/zod/src/v4/locales/hy.ts +2 -0
- package/node_modules/zod/src/v4/locales/id.ts +2 -0
- package/node_modules/zod/src/v4/locales/index.ts +1 -0
- package/node_modules/zod/src/v4/locales/is.ts +2 -0
- package/node_modules/zod/src/v4/locales/it.ts +2 -0
- package/node_modules/zod/src/v4/locales/ja.ts +2 -0
- package/node_modules/zod/src/v4/locales/ka.ts +2 -0
- package/node_modules/zod/src/v4/locales/km.ts +2 -0
- package/node_modules/zod/src/v4/locales/kn.ts +2 -0
- package/node_modules/zod/src/v4/locales/ko.ts +2 -0
- package/node_modules/zod/src/v4/locales/lt.ts +2 -0
- package/node_modules/zod/src/v4/locales/mk.ts +2 -0
- package/node_modules/zod/src/v4/locales/ms.ts +2 -0
- package/node_modules/zod/src/v4/locales/ne.ts +2 -0
- package/node_modules/zod/src/v4/locales/nl.ts +2 -0
- package/node_modules/zod/src/v4/locales/nn.ts +2 -0
- package/node_modules/zod/src/v4/locales/no.ts +2 -0
- package/node_modules/zod/src/v4/locales/ota.ts +2 -0
- package/node_modules/zod/src/v4/locales/pl.ts +2 -0
- package/node_modules/zod/src/v4/locales/ps.ts +2 -0
- package/node_modules/zod/src/v4/locales/pt-BR.ts +2 -0
- package/node_modules/zod/src/v4/locales/pt.ts +2 -0
- package/node_modules/zod/src/v4/locales/ro.ts +2 -0
- package/node_modules/zod/src/v4/locales/ru.ts +2 -0
- package/node_modules/zod/src/v4/locales/sk.ts +2 -0
- package/node_modules/zod/src/v4/locales/sl.ts +2 -0
- package/node_modules/zod/src/v4/locales/sv.ts +2 -0
- package/node_modules/zod/src/v4/locales/ta.ts +2 -0
- package/node_modules/zod/src/v4/locales/tg.ts +135 -0
- package/node_modules/zod/src/v4/locales/th.ts +2 -0
- package/node_modules/zod/src/v4/locales/tk.ts +2 -0
- package/node_modules/zod/src/v4/locales/tr.ts +2 -0
- package/node_modules/zod/src/v4/locales/uk.ts +2 -0
- package/node_modules/zod/src/v4/locales/ur.ts +2 -0
- package/node_modules/zod/src/v4/locales/uz.ts +2 -0
- package/node_modules/zod/src/v4/locales/vi.ts +2 -0
- package/node_modules/zod/src/v4/locales/yo.ts +2 -0
- package/node_modules/zod/src/v4/locales/zh-CN.ts +2 -0
- package/node_modules/zod/src/v4/locales/zh-TW.ts +2 -0
- package/node_modules/zod/src/v4/mini/external.ts +2 -0
- package/node_modules/zod/src/v4/mini/schemas.ts +32 -7
- package/node_modules/zod/src/v4/mini/tests/checks.test.ts +1 -1
- package/node_modules/zod/src/v4/mini/tests/computed.test.ts +11 -17
- package/node_modules/zod/src/v4/mini/tests/index.test.ts +86 -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 +23 -0
- package/node_modules/zod/v3/ZodError.cjs +19 -0
- 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 +19 -0
- package/node_modules/zod/v4/classic/checks.cjs +19 -0
- 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/deep-partial.cjs +19 -0
- package/node_modules/zod/v4/classic/errors.cjs +19 -0
- package/node_modules/zod/v4/classic/external.cjs +22 -1
- package/node_modules/zod/v4/classic/external.d.cts +1 -1
- package/node_modules/zod/v4/classic/external.d.ts +1 -1
- package/node_modules/zod/v4/classic/external.js +1 -1
- package/node_modules/zod/v4/classic/from-json-schema.cjs +264 -24
- package/node_modules/zod/v4/classic/from-json-schema.js +245 -24
- package/node_modules/zod/v4/classic/in-out.cjs +19 -0
- package/node_modules/zod/v4/classic/index.cjs +19 -0
- package/node_modules/zod/v4/classic/iso.cjs +19 -0
- package/node_modules/zod/v4/classic/parse.cjs +19 -0
- package/node_modules/zod/v4/classic/schemas.cjs +100 -35
- package/node_modules/zod/v4/classic/schemas.d.cts +15 -1
- package/node_modules/zod/v4/classic/schemas.d.ts +15 -1
- package/node_modules/zod/v4/classic/schemas.js +77 -33
- package/node_modules/zod/v4/core/api.cjs +45 -22
- package/node_modules/zod/v4/core/api.d.cts +12 -6
- package/node_modules/zod/v4/core/api.d.ts +12 -6
- package/node_modules/zod/v4/core/api.js +25 -22
- package/node_modules/zod/v4/core/checks.cjs +51 -97
- package/node_modules/zod/v4/core/checks.d.cts +17 -1
- package/node_modules/zod/v4/core/checks.d.ts +17 -1
- package/node_modules/zod/v4/core/checks.js +31 -96
- package/node_modules/zod/v4/core/compile.cjs +173 -78
- package/node_modules/zod/v4/core/compile.d.cts +18 -4
- package/node_modules/zod/v4/core/compile.d.ts +18 -4
- package/node_modules/zod/v4/core/compile.js +154 -79
- package/node_modules/zod/v4/core/core.cjs +20 -1
- package/node_modules/zod/v4/core/core.js +1 -1
- package/node_modules/zod/v4/core/doc.cjs +26 -2
- package/node_modules/zod/v4/core/doc.js +7 -2
- package/node_modules/zod/v4/core/errors.cjs +21 -5
- package/node_modules/zod/v4/core/errors.js +2 -5
- package/node_modules/zod/v4/core/index.cjs +19 -0
- package/node_modules/zod/v4/core/json-schema-generator.cjs +20 -1
- package/node_modules/zod/v4/core/json-schema-generator.js +2 -2
- package/node_modules/zod/v4/core/json-schema-processors.cjs +188 -72
- 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 +170 -74
- package/node_modules/zod/v4/core/json-schema.cjs +19 -0
- package/node_modules/zod/v4/core/memoizer.cjs +111 -23
- package/node_modules/zod/v4/core/memoizer.js +69 -23
- package/node_modules/zod/v4/core/parse.cjs +56 -16
- package/node_modules/zod/v4/core/parse.js +37 -16
- package/node_modules/zod/v4/core/regexes.cjs +31 -6
- package/node_modules/zod/v4/core/regexes.d.cts +3 -0
- package/node_modules/zod/v4/core/regexes.d.ts +3 -0
- package/node_modules/zod/v4/core/regexes.js +10 -4
- package/node_modules/zod/v4/core/registries.cjs +19 -0
- package/node_modules/zod/v4/core/schemas.cjs +302 -114
- package/node_modules/zod/v4/core/schemas.d.cts +28 -8
- package/node_modules/zod/v4/core/schemas.d.ts +28 -8
- package/node_modules/zod/v4/core/schemas.js +279 -113
- package/node_modules/zod/v4/core/standard-schema.cjs +19 -0
- package/node_modules/zod/v4/core/to-json-schema.cjs +28 -7
- package/node_modules/zod/v4/core/to-json-schema.d.cts +4 -3
- package/node_modules/zod/v4/core/to-json-schema.d.ts +4 -3
- package/node_modules/zod/v4/core/to-json-schema.js +7 -6
- package/node_modules/zod/v4/core/util.cjs +177 -143
- package/node_modules/zod/v4/core/util.d.cts +25 -4
- package/node_modules/zod/v4/core/util.d.ts +25 -4
- package/node_modules/zod/v4/core/util.js +156 -143
- 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 +19 -0
- package/node_modules/zod/v4/index.cjs +19 -0
- package/node_modules/zod/v4/locales/ar.cjs +2 -0
- package/node_modules/zod/v4/locales/ar.js +2 -0
- package/node_modules/zod/v4/locales/az.cjs +2 -0
- package/node_modules/zod/v4/locales/az.js +2 -0
- package/node_modules/zod/v4/locales/be.cjs +2 -0
- package/node_modules/zod/v4/locales/be.js +2 -0
- package/node_modules/zod/v4/locales/bg.cjs +2 -0
- package/node_modules/zod/v4/locales/bg.js +2 -0
- package/node_modules/zod/v4/locales/bn.cjs +2 -0
- package/node_modules/zod/v4/locales/bn.js +2 -0
- package/node_modules/zod/v4/locales/ca.cjs +2 -0
- package/node_modules/zod/v4/locales/ca.js +2 -0
- package/node_modules/zod/v4/locales/ckb.cjs +2 -0
- package/node_modules/zod/v4/locales/ckb.js +2 -0
- package/node_modules/zod/v4/locales/cs.cjs +2 -0
- package/node_modules/zod/v4/locales/cs.js +2 -0
- package/node_modules/zod/v4/locales/da.cjs +2 -0
- package/node_modules/zod/v4/locales/da.js +2 -0
- package/node_modules/zod/v4/locales/de.cjs +2 -0
- package/node_modules/zod/v4/locales/de.js +2 -0
- package/node_modules/zod/v4/locales/el.cjs +2 -0
- package/node_modules/zod/v4/locales/el.js +2 -0
- package/node_modules/zod/v4/locales/en.cjs +2 -0
- package/node_modules/zod/v4/locales/en.js +2 -0
- package/node_modules/zod/v4/locales/eo.cjs +2 -0
- package/node_modules/zod/v4/locales/eo.js +2 -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 +2 -0
- package/node_modules/zod/v4/locales/fa.js +2 -0
- package/node_modules/zod/v4/locales/fi.cjs +2 -0
- package/node_modules/zod/v4/locales/fi.js +2 -0
- package/node_modules/zod/v4/locales/fr-CA.cjs +2 -0
- package/node_modules/zod/v4/locales/fr-CA.js +2 -0
- package/node_modules/zod/v4/locales/fr.cjs +2 -0
- package/node_modules/zod/v4/locales/fr.js +2 -0
- package/node_modules/zod/v4/locales/gu.cjs +2 -0
- package/node_modules/zod/v4/locales/gu.js +2 -0
- package/node_modules/zod/v4/locales/he.cjs +2 -0
- package/node_modules/zod/v4/locales/he.js +2 -0
- package/node_modules/zod/v4/locales/hi.cjs +2 -0
- package/node_modules/zod/v4/locales/hi.js +2 -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 +2 -0
- package/node_modules/zod/v4/locales/hu.js +2 -0
- package/node_modules/zod/v4/locales/hy.cjs +2 -0
- package/node_modules/zod/v4/locales/hy.js +2 -0
- package/node_modules/zod/v4/locales/id.cjs +2 -0
- package/node_modules/zod/v4/locales/id.js +2 -0
- package/node_modules/zod/v4/locales/index.cjs +22 -1
- package/node_modules/zod/v4/locales/index.d.cts +1 -0
- package/node_modules/zod/v4/locales/index.d.ts +1 -0
- package/node_modules/zod/v4/locales/index.js +1 -0
- package/node_modules/zod/v4/locales/is.cjs +2 -0
- package/node_modules/zod/v4/locales/is.js +2 -0
- package/node_modules/zod/v4/locales/it.cjs +2 -0
- package/node_modules/zod/v4/locales/it.js +2 -0
- package/node_modules/zod/v4/locales/ja.cjs +2 -0
- package/node_modules/zod/v4/locales/ja.js +2 -0
- package/node_modules/zod/v4/locales/ka.cjs +2 -0
- package/node_modules/zod/v4/locales/ka.js +2 -0
- package/node_modules/zod/v4/locales/km.cjs +2 -0
- package/node_modules/zod/v4/locales/km.js +2 -0
- package/node_modules/zod/v4/locales/kn.cjs +2 -0
- package/node_modules/zod/v4/locales/kn.js +2 -0
- package/node_modules/zod/v4/locales/ko.cjs +2 -0
- package/node_modules/zod/v4/locales/ko.js +2 -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 +2 -0
- package/node_modules/zod/v4/locales/mk.js +2 -0
- package/node_modules/zod/v4/locales/ms.cjs +2 -0
- package/node_modules/zod/v4/locales/ms.js +2 -0
- package/node_modules/zod/v4/locales/ne.cjs +2 -0
- package/node_modules/zod/v4/locales/ne.js +2 -0
- package/node_modules/zod/v4/locales/nl.cjs +2 -0
- package/node_modules/zod/v4/locales/nl.js +2 -0
- package/node_modules/zod/v4/locales/nn.cjs +2 -0
- package/node_modules/zod/v4/locales/nn.js +2 -0
- package/node_modules/zod/v4/locales/no.cjs +2 -0
- package/node_modules/zod/v4/locales/no.js +2 -0
- package/node_modules/zod/v4/locales/ota.cjs +2 -0
- package/node_modules/zod/v4/locales/ota.js +2 -0
- package/node_modules/zod/v4/locales/pl.cjs +2 -0
- package/node_modules/zod/v4/locales/pl.js +2 -0
- package/node_modules/zod/v4/locales/ps.cjs +2 -0
- package/node_modules/zod/v4/locales/ps.js +2 -0
- package/node_modules/zod/v4/locales/pt-BR.cjs +2 -0
- package/node_modules/zod/v4/locales/pt-BR.js +2 -0
- package/node_modules/zod/v4/locales/pt.cjs +2 -0
- package/node_modules/zod/v4/locales/pt.js +2 -0
- package/node_modules/zod/v4/locales/ro.cjs +2 -0
- package/node_modules/zod/v4/locales/ro.js +2 -0
- package/node_modules/zod/v4/locales/ru.cjs +2 -0
- package/node_modules/zod/v4/locales/ru.js +2 -0
- package/node_modules/zod/v4/locales/sk.cjs +2 -0
- package/node_modules/zod/v4/locales/sk.js +2 -0
- package/node_modules/zod/v4/locales/sl.cjs +2 -0
- package/node_modules/zod/v4/locales/sl.js +2 -0
- package/node_modules/zod/v4/locales/sv.cjs +2 -0
- package/node_modules/zod/v4/locales/sv.js +2 -0
- package/node_modules/zod/v4/locales/ta.cjs +2 -0
- package/node_modules/zod/v4/locales/ta.js +2 -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 +2 -0
- package/node_modules/zod/v4/locales/th.js +2 -0
- package/node_modules/zod/v4/locales/tk.cjs +2 -0
- package/node_modules/zod/v4/locales/tk.js +2 -0
- package/node_modules/zod/v4/locales/tr.cjs +2 -0
- package/node_modules/zod/v4/locales/tr.js +2 -0
- package/node_modules/zod/v4/locales/uk.cjs +2 -0
- package/node_modules/zod/v4/locales/uk.js +2 -0
- package/node_modules/zod/v4/locales/ur.cjs +2 -0
- package/node_modules/zod/v4/locales/ur.js +2 -0
- package/node_modules/zod/v4/locales/uz.cjs +2 -0
- package/node_modules/zod/v4/locales/uz.js +2 -0
- package/node_modules/zod/v4/locales/vi.cjs +2 -0
- package/node_modules/zod/v4/locales/vi.js +2 -0
- package/node_modules/zod/v4/locales/yo.cjs +2 -0
- package/node_modules/zod/v4/locales/yo.js +2 -0
- package/node_modules/zod/v4/locales/zh-CN.cjs +2 -0
- package/node_modules/zod/v4/locales/zh-CN.js +2 -0
- package/node_modules/zod/v4/locales/zh-TW.cjs +2 -0
- package/node_modules/zod/v4/locales/zh-TW.js +2 -0
- package/node_modules/zod/v4/mini/checks.cjs +19 -0
- package/node_modules/zod/v4/mini/coerce.cjs +19 -0
- package/node_modules/zod/v4/mini/deep-partial.cjs +19 -0
- package/node_modules/zod/v4/mini/external.cjs +22 -1
- package/node_modules/zod/v4/mini/external.d.cts +1 -1
- package/node_modules/zod/v4/mini/external.d.ts +1 -1
- package/node_modules/zod/v4/mini/external.js +1 -1
- package/node_modules/zod/v4/mini/in-out.cjs +19 -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 +19 -0
- package/node_modules/zod/v4/mini/schemas.cjs +44 -8
- package/node_modules/zod/v4/mini/schemas.d.cts +6 -1
- package/node_modules/zod/v4/mini/schemas.d.ts +6 -1
- package/node_modules/zod/v4/mini/schemas.js +21 -6
- package/node_modules/zod/v4-mini/index.cjs +19 -0
- package/openclaw.plugin.json +20 -0
- package/package.json +5 -5
- package/dist/.setup/doctor-contract-mvORF4f6.mjs +0 -18
|
@@ -1,183 +1,44 @@
|
|
|
1
|
+
import { a as resolveInteractionCallbackPath, c as setInteractionSecret, i as createMattermostInteractionHandler, n as buildButtonProps, r as computeInteractionCallbackUrl, s as setInteractionCallbackUrl, u as gateway_config_runtime_exports } from "./interactions-DMSZYnEx.mjs";
|
|
1
2
|
import { n as getOptionalMattermostRuntime, t as getMattermostRuntime } from "./runtime-CNB4YGqJ.mjs";
|
|
2
|
-
import { a as
|
|
3
|
-
import { _ as
|
|
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-DBoM2Bja.mjs";
|
|
3
|
+
import { a as createMattermostPost, d as fetchMattermostUser, h as normalizeMattermostBaseUrl, 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-CVeeTqCO.mjs";
|
|
4
|
+
import { C as resolveAllowlistProviderRuntimeGroupPolicy, 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-aZ0b1gqx.mjs";
|
|
5
5
|
import { n as normalizeMattermostAllowEntry } from "./ingress-identity-DNl4yQSc.mjs";
|
|
6
|
-
import {
|
|
7
|
-
import { _ as
|
|
6
|
+
import { d as resolveMattermostReplyToMode, r as parseMattermostQuestionContext, u as resolveMattermostAccount } from "./normalize-BCjtmxtp.mjs";
|
|
7
|
+
import { _ as resolveSlashCommandConfig, a as deliverMattermostReplyPayload, c as parseMattermostModelPickerContext, d as resolveMattermostModelPickerCurrentModel, f as DEFAULT_COMMAND_SPECS, g as resolveCallbackUrl, h as registerSlashCommands, l as renderMattermostModelsPickerView, m as isSlashCommandsEnabled, n as deactivateSlashCommands, o as joinMattermostVisibleContent, p as cleanupSlashCommands, r as getSlashCommandState, s as buildMattermostAllowedModelRefs, t as activateSlashCommands, u as renderMattermostProviderPickerView } from "./slash-state-Dni1XNc1.mjs";
|
|
8
|
+
import { t as sendMessageMattermost } from "./send-ClgX-usq.mjs";
|
|
8
9
|
import { randomUUID } from "node:crypto";
|
|
9
|
-
import { resolveGatewayPort } from "openclaw/plugin-sdk/gateway-config-runtime";
|
|
10
10
|
import { resolvePinnedMainDmOwnerFromAllowlist, sanitizeUntrustedFileName } from "openclaw/plugin-sdk/security-runtime";
|
|
11
11
|
import { normalizeLowercaseStringOrEmpty, normalizeOptionalString, normalizeStringEntries, normalizeTrimmedStringList, uniqueStrings } from "openclaw/plugin-sdk/string-coerce-runtime";
|
|
12
12
|
import { buildChannelInboundMediaPayload, createAcceptedChannelDeliveryResult, createChannelPartialDeliveryError, formatInboundEnvelope, formatInboundFromLabel, formatInboundMediaUnavailableText, formatMediaPlaceholderText, implicitMentionKindWhen, isChannelPartialDeliveryError, resolveInboundMentionDecision, resolveInboundSessionEnvelopeContext, toInboundMediaFactsWithMetadata } from "openclaw/plugin-sdk/channel-inbound";
|
|
13
13
|
import { formatErrorMessage, toErrorObject } from "openclaw/plugin-sdk/error-runtime";
|
|
14
14
|
import { safeParseJsonWithSchema, safeParseWithSchema } from "openclaw/plugin-sdk/extension-shared";
|
|
15
|
-
import { asDateTimestampMs, resolveExpiresAtMsFromDurationMs,
|
|
16
|
-
import {
|
|
17
|
-
import { fetchWithSsrFGuard, isPrivateNetworkOptInEnabled, ssrfPolicyFromPrivateNetworkOptIn } from "openclaw/plugin-sdk/ssrf-runtime";
|
|
15
|
+
import { asDateTimestampMs, resolveExpiresAtMsFromDurationMs, resolvePromptHistoryLimit } from "openclaw/plugin-sdk/number-runtime";
|
|
16
|
+
import { isPrivateNetworkOptInEnabled } from "openclaw/plugin-sdk/ssrf-runtime";
|
|
18
17
|
import { z } from "zod";
|
|
19
|
-
import { bindIngressLifecycleToReplyOptions,
|
|
20
|
-
import { resolveAllowlistProviderRuntimeGroupPolicy } from "openclaw/plugin-sdk/runtime-group-policy";
|
|
18
|
+
import { bindIngressLifecycleToReplyOptions, createChannelIngressError, createChannelIngressMonitor, createChannelProgressDraftCompositor, createFinalizableDraftLifecycle, createLivePreviewLifecycle, createMessageReceiptFromOutboundResults, createPreviewMessageReceipt, listMessageReceiptPlatformIds, resolveChannelStreamingPreviewToolProgress } from "openclaw/plugin-sdk/channel-outbound";
|
|
21
19
|
import { rawDataToString } from "openclaw/plugin-sdk/webhook-ingress";
|
|
22
20
|
import { runDetachedWebhookWork } from "openclaw/plugin-sdk/webhook-request-guards";
|
|
23
21
|
import { fanInChannelIngressLifecycles, resolveChannelImplicitMentions } from "openclaw/plugin-sdk/channel-ingress-runtime";
|
|
24
22
|
import { resolveChannelGroups, resolveChannelGroupsConfigPath } from "openclaw/plugin-sdk/channel-policy";
|
|
25
23
|
import { buildTtsSupplementMediaPayload, countOutboundMedia, getReplyPayloadTtsSupplement, isReasoningReplyPayload, resolveSendableOutboundReplyParts } from "openclaw/plugin-sdk/reply-payload";
|
|
26
|
-
import { normalizeAccountId } from "openclaw/plugin-sdk/account-id";
|
|
27
24
|
import { isRecord } from "openclaw/plugin-sdk/channel-secret-basic-runtime";
|
|
28
|
-
import {
|
|
29
|
-
import { resolveInboundLastRouteSessionKey, resolveThreadSessionKeys } from "openclaw/plugin-sdk/routing";
|
|
30
|
-
import { escapeRegExp, runChannelProbe, sliceUtf16Safe, truncateUtf16Safe } from "openclaw/plugin-sdk/text-utility-runtime";
|
|
25
|
+
import { escapeRegExp, sliceUtf16Safe, truncateUtf16Safe } from "openclaw/plugin-sdk/text-utility-runtime";
|
|
31
26
|
import { resolveHumanDelayConfig } from "openclaw/plugin-sdk/agent-runtime";
|
|
32
|
-
import { finalizeInboundContext } from "openclaw/plugin-sdk/reply-runtime";
|
|
33
27
|
import { pruneMapToMaxSize } from "openclaw/plugin-sdk/collection-runtime";
|
|
28
|
+
import { finalizeInboundContext } from "openclaw/plugin-sdk/reply-runtime";
|
|
29
|
+
import { getSessionEntry, resolveStorePath } from "openclaw/plugin-sdk/session-store-runtime";
|
|
34
30
|
import { channelReadyPatch, isLoopbackHost } from "openclaw/plugin-sdk/gateway-runtime";
|
|
35
31
|
import { createRuntimeConfigReader } from "openclaw/plugin-sdk/runtime-config-snapshot";
|
|
36
|
-
import
|
|
32
|
+
import * as proxyCaptureSdk from "openclaw/plugin-sdk/proxy-capture";
|
|
33
|
+
import { createDebugProxyWebSocketAgent, resolveDebugProxySettings } from "openclaw/plugin-sdk/proxy-capture";
|
|
37
34
|
import { WebSocket } from "openclaw/plugin-sdk/websocket-runtime";
|
|
38
35
|
import { questionGatewayRuntime } from "openclaw/plugin-sdk/question-gateway-runtime";
|
|
36
|
+
import { resolveInboundLastRouteSessionKey, resolveThreadSessionKeys } from "openclaw/plugin-sdk/routing";
|
|
39
37
|
import { getGlobalHookRunner } from "openclaw/plugin-sdk/plugin-runtime";
|
|
40
38
|
import { chunkMarkdownTextWithMode } from "openclaw/plugin-sdk/reply-chunking";
|
|
41
39
|
import { createPersistentDedupeCache } from "openclaw/plugin-sdk/dedupe-runtime";
|
|
42
40
|
import { createPluginStateErrorReporter } from "openclaw/plugin-sdk/plugin-state-runtime";
|
|
43
|
-
//#region extensions/mattermost/src/mattermost/directory.ts
|
|
44
|
-
function buildClient(params) {
|
|
45
|
-
const account = inspectMattermostAccount({
|
|
46
|
-
cfg: params.cfg,
|
|
47
|
-
accountId: params.accountId
|
|
48
|
-
});
|
|
49
|
-
if (!account.enabled || !account.botToken || !account.baseUrl) return null;
|
|
50
|
-
return createMattermostClient({
|
|
51
|
-
baseUrl: account.baseUrl,
|
|
52
|
-
botToken: account.botToken,
|
|
53
|
-
allowPrivateNetwork: isPrivateNetworkOptInEnabled(account.config)
|
|
54
|
-
});
|
|
55
|
-
}
|
|
56
|
-
/** Build the requested account client, or aggregate accounts for an explicitly unscoped lookup. */
|
|
57
|
-
function buildClients(params) {
|
|
58
|
-
const requestedAccountId = params.accountId?.trim();
|
|
59
|
-
const accountIds = requestedAccountId ? [requestedAccountId] : listMattermostAccountIds(params.cfg);
|
|
60
|
-
const seen = /* @__PURE__ */ new Set();
|
|
61
|
-
const clients = [];
|
|
62
|
-
for (const id of accountIds) {
|
|
63
|
-
const client = buildClient({
|
|
64
|
-
cfg: params.cfg,
|
|
65
|
-
accountId: id
|
|
66
|
-
});
|
|
67
|
-
if (client && !seen.has(client.token)) {
|
|
68
|
-
seen.add(client.token);
|
|
69
|
-
clients.push(client);
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
return clients;
|
|
73
|
-
}
|
|
74
|
-
/**
|
|
75
|
-
* List channels (public + private) visible to any configured bot account.
|
|
76
|
-
*
|
|
77
|
-
* NOTE: Uses per_page=200 which covers most instances. Mattermost does not
|
|
78
|
-
* return a "has more" indicator, so very large instances (200+ channels per bot)
|
|
79
|
-
* may see incomplete results. Pagination can be added if needed.
|
|
80
|
-
*/
|
|
81
|
-
async function listMattermostDirectoryGroups(params) {
|
|
82
|
-
const clients = buildClients(params);
|
|
83
|
-
if (!clients.length) return [];
|
|
84
|
-
const q = normalizeLowercaseStringOrEmpty(params.query);
|
|
85
|
-
const seenIds = /* @__PURE__ */ new Set();
|
|
86
|
-
const entries = [];
|
|
87
|
-
for (const client of clients) try {
|
|
88
|
-
const me = await fetchMattermostMe(client);
|
|
89
|
-
const channels = await client.request(`/users/${me.id}/channels?per_page=200`);
|
|
90
|
-
for (const ch of channels) {
|
|
91
|
-
if (ch.type !== "O" && ch.type !== "P") continue;
|
|
92
|
-
if (seenIds.has(ch.id)) continue;
|
|
93
|
-
if (q) {
|
|
94
|
-
const name = normalizeLowercaseStringOrEmpty(ch.name);
|
|
95
|
-
const display = normalizeLowercaseStringOrEmpty(ch.display_name);
|
|
96
|
-
if (!name.includes(q) && !display.includes(q)) continue;
|
|
97
|
-
}
|
|
98
|
-
seenIds.add(ch.id);
|
|
99
|
-
entries.push({
|
|
100
|
-
kind: resolveMattermostTrustedChatKind({ channelType: ch.type }) === "group" ? "group" : "channel",
|
|
101
|
-
id: `channel:${ch.id}`,
|
|
102
|
-
name: ch.name ?? void 0,
|
|
103
|
-
handle: ch.display_name ?? void 0
|
|
104
|
-
});
|
|
105
|
-
}
|
|
106
|
-
} catch (err) {
|
|
107
|
-
console.debug?.("[mattermost-directory] listGroups: skipping account:", err?.message);
|
|
108
|
-
continue;
|
|
109
|
-
}
|
|
110
|
-
return params.limit && params.limit > 0 ? entries.slice(0, params.limit) : entries;
|
|
111
|
-
}
|
|
112
|
-
/**
|
|
113
|
-
* List team members as peer directory entries.
|
|
114
|
-
*
|
|
115
|
-
* Uses only the first available client since all bots in a team see the same
|
|
116
|
-
* user list (unlike channels where membership varies). Uses the first team
|
|
117
|
-
* returned — multi-team setups will only see members from that team.
|
|
118
|
-
*
|
|
119
|
-
* Uses paginated member listing with per_page=200, the Mattermost API maximum.
|
|
120
|
-
*/
|
|
121
|
-
async function listMattermostDirectoryPeers(params) {
|
|
122
|
-
const clients = buildClients(params);
|
|
123
|
-
if (!clients.length) return [];
|
|
124
|
-
const client = clients[0];
|
|
125
|
-
if (!client) return [];
|
|
126
|
-
try {
|
|
127
|
-
const me = await fetchMattermostMe(client);
|
|
128
|
-
const teams = await client.request("/users/me/teams");
|
|
129
|
-
if (!teams.length) return [];
|
|
130
|
-
const team = teams[0];
|
|
131
|
-
if (!team) return [];
|
|
132
|
-
const teamId = team.id;
|
|
133
|
-
const q = normalizeLowercaseStringOrEmpty(params.query);
|
|
134
|
-
let users;
|
|
135
|
-
if (q) users = await client.request("/users/search", {
|
|
136
|
-
method: "POST",
|
|
137
|
-
body: JSON.stringify({
|
|
138
|
-
term: q,
|
|
139
|
-
team_id: teamId
|
|
140
|
-
})
|
|
141
|
-
});
|
|
142
|
-
else {
|
|
143
|
-
const pageSize = 200;
|
|
144
|
-
const userIds = [];
|
|
145
|
-
for (let page = 0;; page += 1) {
|
|
146
|
-
const pageMembers = await client.request(`/teams/${teamId}/members?page=${page}&per_page=${pageSize}`);
|
|
147
|
-
for (const member of pageMembers) if (member.user_id !== me.id) userIds.push(member.user_id);
|
|
148
|
-
if (pageMembers.length < pageSize) break;
|
|
149
|
-
}
|
|
150
|
-
if (!userIds.length) return [];
|
|
151
|
-
users = [];
|
|
152
|
-
for (let index = 0; index < userIds.length; index += pageSize) {
|
|
153
|
-
const userIdBatch = userIds.slice(index, index + pageSize);
|
|
154
|
-
users.push(...await client.request("/users/ids", {
|
|
155
|
-
method: "POST",
|
|
156
|
-
body: JSON.stringify(userIdBatch)
|
|
157
|
-
}));
|
|
158
|
-
}
|
|
159
|
-
}
|
|
160
|
-
const entries = users.filter((u) => u.id !== me.id).map((u) => ({
|
|
161
|
-
kind: "user",
|
|
162
|
-
id: `user:${u.id}`,
|
|
163
|
-
name: u.username ?? void 0,
|
|
164
|
-
handle: [u.first_name, u.last_name].filter(Boolean).join(" ").trim() || u.nickname || void 0
|
|
165
|
-
}));
|
|
166
|
-
return params.limit && params.limit > 0 ? entries.slice(0, params.limit) : entries;
|
|
167
|
-
} catch (err) {
|
|
168
|
-
console.debug?.("[mattermost-directory] listPeers failed:", err?.message);
|
|
169
|
-
return [];
|
|
170
|
-
}
|
|
171
|
-
}
|
|
172
|
-
//#endregion
|
|
173
41
|
//#region extensions/mattermost/src/mattermost/monitor-helpers.ts
|
|
174
|
-
const formatInboundFromLabel$1 = formatInboundFromLabel;
|
|
175
|
-
function resolveThreadSessionKeys$1(params) {
|
|
176
|
-
return resolveThreadSessionKeys({
|
|
177
|
-
...params,
|
|
178
|
-
normalizeThreadId: (threadId) => threadId
|
|
179
|
-
});
|
|
180
|
-
}
|
|
181
42
|
function buildMattermostBotMentionPattern(username) {
|
|
182
43
|
return `(?<![a-z0-9_])@${escapeRegExp(username)}(?![a-z0-9_]|[.:-]+[a-z0-9_])`;
|
|
183
44
|
}
|
|
@@ -218,6 +79,7 @@ function shouldDropEmptyMattermostBody(params) {
|
|
|
218
79
|
}
|
|
219
80
|
//#endregion
|
|
220
81
|
//#region extensions/mattermost/src/mattermost/monitor-websocket.ts
|
|
82
|
+
const captureSdk = proxyCaptureSdk;
|
|
221
83
|
const MATTERMOST_WEBSOCKET_MAX_PAYLOAD_BYTES = 16777216;
|
|
222
84
|
const MATTERMOST_WEBSOCKET_HANDSHAKE_TIMEOUT_MS = 3e4;
|
|
223
85
|
const MATTERMOST_WEBSOCKET_AUTH_TIMEOUT_MS = 3e4;
|
|
@@ -300,22 +162,14 @@ function createMattermostConnectOnce(opts) {
|
|
|
300
162
|
let authenticationSeq;
|
|
301
163
|
let authTimer;
|
|
302
164
|
const clearTimers = () => {
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
if (protocolPingTimer !== void 0) {
|
|
312
|
-
clearTimeout(protocolPingTimer);
|
|
313
|
-
protocolPingTimer = void 0;
|
|
314
|
-
}
|
|
315
|
-
if (protocolPongTimer !== void 0) {
|
|
316
|
-
clearTimeout(protocolPongTimer);
|
|
317
|
-
protocolPongTimer = void 0;
|
|
318
|
-
}
|
|
165
|
+
clearTimeout(healthCheckTimer);
|
|
166
|
+
healthCheckTimer = void 0;
|
|
167
|
+
clearTimeout(authTimer);
|
|
168
|
+
authTimer = void 0;
|
|
169
|
+
clearTimeout(protocolPingTimer);
|
|
170
|
+
protocolPingTimer = void 0;
|
|
171
|
+
clearTimeout(protocolPongTimer);
|
|
172
|
+
protocolPongTimer = void 0;
|
|
319
173
|
};
|
|
320
174
|
const stopHealthChecks = () => {
|
|
321
175
|
healthCheckEnabled = false;
|
|
@@ -324,7 +178,7 @@ function createMattermostConnectOnce(opts) {
|
|
|
324
178
|
};
|
|
325
179
|
const sendProtocolPing = () => {
|
|
326
180
|
if (!protocolKeepaliveEnabled || settled) return;
|
|
327
|
-
|
|
181
|
+
clearTimeout(protocolPongTimer);
|
|
328
182
|
protocolPongTimer = setTimeout(() => {
|
|
329
183
|
protocolPongTimer = void 0;
|
|
330
184
|
if (!protocolKeepaliveEnabled || settled) return;
|
|
@@ -393,13 +247,13 @@ function createMattermostConnectOnce(opts) {
|
|
|
393
247
|
};
|
|
394
248
|
ws.on("open", () => {
|
|
395
249
|
opened = true;
|
|
396
|
-
|
|
250
|
+
captureSdk.captureWsEventAsync?.({
|
|
397
251
|
url: opts.wsUrl,
|
|
398
252
|
direction: "local",
|
|
399
253
|
kind: "ws-open",
|
|
400
254
|
flowId,
|
|
401
255
|
meta: { subsystem: "mattermost-websocket" }
|
|
402
|
-
});
|
|
256
|
+
}).catch(() => {});
|
|
403
257
|
opts.statusSink?.({
|
|
404
258
|
connected: true,
|
|
405
259
|
lifecycle: "starting"
|
|
@@ -410,7 +264,7 @@ function createMattermostConnectOnce(opts) {
|
|
|
410
264
|
action: "authentication_challenge",
|
|
411
265
|
data: { token: opts.botToken }
|
|
412
266
|
});
|
|
413
|
-
|
|
267
|
+
captureSdk.captureWsEventAsync?.({
|
|
414
268
|
url: opts.wsUrl,
|
|
415
269
|
direction: "outbound",
|
|
416
270
|
kind: "ws-frame",
|
|
@@ -420,7 +274,7 @@ function createMattermostConnectOnce(opts) {
|
|
|
420
274
|
subsystem: "mattermost-websocket",
|
|
421
275
|
eventType: "authentication_challenge"
|
|
422
276
|
}
|
|
423
|
-
});
|
|
277
|
+
}).catch(() => {});
|
|
424
278
|
ws.send(authPayload);
|
|
425
279
|
authTimer = setTimeout(() => {
|
|
426
280
|
authTimer = void 0;
|
|
@@ -433,30 +287,26 @@ function createMattermostConnectOnce(opts) {
|
|
|
433
287
|
if (getBotUpdateAt) runHealthCheck();
|
|
434
288
|
});
|
|
435
289
|
ws.on("pong", () => {
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
protocolPongTimer = void 0;
|
|
439
|
-
}
|
|
290
|
+
clearTimeout(protocolPongTimer);
|
|
291
|
+
protocolPongTimer = void 0;
|
|
440
292
|
scheduleProtocolPing();
|
|
441
293
|
});
|
|
442
294
|
ws.on("message", async (data) => {
|
|
443
295
|
const raw = rawDataToString(data);
|
|
444
|
-
|
|
296
|
+
captureSdk.captureWsEventAsync?.({
|
|
445
297
|
url: opts.wsUrl,
|
|
446
298
|
direction: "inbound",
|
|
447
299
|
kind: "ws-frame",
|
|
448
300
|
flowId,
|
|
449
301
|
payload: Buffer.from(raw),
|
|
450
302
|
meta: { subsystem: "mattermost-websocket" }
|
|
451
|
-
});
|
|
303
|
+
}).catch(() => {});
|
|
452
304
|
const payload = parseMattermostEventPayload(raw);
|
|
453
305
|
if (!payload) return;
|
|
454
306
|
if (payload.status === "OK" && payload.seq_reply === authenticationSeq) {
|
|
455
307
|
authenticated = true;
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
authTimer = void 0;
|
|
459
|
-
}
|
|
308
|
+
clearTimeout(authTimer);
|
|
309
|
+
authTimer = void 0;
|
|
460
310
|
opts.statusSink?.(channelReadyPatch());
|
|
461
311
|
return;
|
|
462
312
|
}
|
|
@@ -478,7 +328,7 @@ function createMattermostConnectOnce(opts) {
|
|
|
478
328
|
}
|
|
479
329
|
});
|
|
480
330
|
ws.on("close", (code, reason) => {
|
|
481
|
-
|
|
331
|
+
captureSdk.captureWsEventAsync?.({
|
|
482
332
|
url: opts.wsUrl,
|
|
483
333
|
direction: "local",
|
|
484
334
|
kind: "ws-close",
|
|
@@ -486,9 +336,9 @@ function createMattermostConnectOnce(opts) {
|
|
|
486
336
|
closeCode: code,
|
|
487
337
|
payload: reason,
|
|
488
338
|
meta: { subsystem: "mattermost-websocket" }
|
|
489
|
-
});
|
|
339
|
+
}).catch(() => {});
|
|
490
340
|
stopHealthChecks();
|
|
491
|
-
const message =
|
|
341
|
+
const message = reason.toString("utf8");
|
|
492
342
|
opts.statusSink?.({
|
|
493
343
|
connected: false,
|
|
494
344
|
lifecycle: "recovering",
|
|
@@ -509,14 +359,14 @@ function createMattermostConnectOnce(opts) {
|
|
|
509
359
|
rejectOnce(new WebSocketClosedBeforeOpenError(code, message || void 0));
|
|
510
360
|
});
|
|
511
361
|
ws.on("error", (err) => {
|
|
512
|
-
|
|
362
|
+
captureSdk.captureWsEventAsync?.({
|
|
513
363
|
url: opts.wsUrl,
|
|
514
364
|
direction: "local",
|
|
515
365
|
kind: "error",
|
|
516
366
|
flowId,
|
|
517
367
|
errorText: String(err),
|
|
518
368
|
meta: { subsystem: "mattermost-websocket" }
|
|
519
|
-
});
|
|
369
|
+
}).catch(() => {});
|
|
520
370
|
opts.runtime.error?.(`mattermost websocket error: ${String(err)}`);
|
|
521
371
|
opts.statusSink?.({
|
|
522
372
|
connected: false,
|
|
@@ -533,11 +383,6 @@ function createMattermostConnectOnce(opts) {
|
|
|
533
383
|
}
|
|
534
384
|
};
|
|
535
385
|
}
|
|
536
|
-
function reasonToString(reason) {
|
|
537
|
-
if (!reason) return "";
|
|
538
|
-
if (typeof reason === "string") return reason;
|
|
539
|
-
return reason.length > 0 ? reason.toString("utf8") : "";
|
|
540
|
-
}
|
|
541
386
|
//#endregion
|
|
542
387
|
//#region extensions/mattermost/src/mattermost/monitor-ingress.ts
|
|
543
388
|
const MATTERMOST_INGRESS_PAYLOAD_VERSION = 1;
|
|
@@ -604,7 +449,7 @@ function resolveMattermostIngressNonRetryableFailure(error) {
|
|
|
604
449
|
function createMattermostIngressMonitor(options) {
|
|
605
450
|
const monitor = createChannelIngressMonitor({
|
|
606
451
|
queue: options.queue ?? (() => getMattermostRuntime().state.openChannelIngressQueue({ accountId: options.accountId })),
|
|
607
|
-
inspect:
|
|
452
|
+
inspect: inspectMattermostIngressEvent,
|
|
608
453
|
payload: {
|
|
609
454
|
version: MATTERMOST_INGRESS_PAYLOAD_VERSION,
|
|
610
455
|
serialize: (rawEvent, { receivedAt }) => ({
|
|
@@ -657,20 +502,7 @@ function createMattermostIngressMonitor(options) {
|
|
|
657
502
|
}
|
|
658
503
|
//#endregion
|
|
659
504
|
//#region extensions/mattermost/src/mattermost/no-visible-reply-diagnostic.ts
|
|
660
|
-
/**
|
|
661
|
-
* Detects the #80501 symptom: `deliverMattermostReplyPayload` accepted a
|
|
662
|
-
* substantive (non-reasoning) payload, called the underlying
|
|
663
|
-
* `deliverTextOrMediaReply`, and the outcome was `"empty"` — meaning the
|
|
664
|
-
* payload had no text and no media to send, so no Mattermost API call
|
|
665
|
-
* happened. The agent's run completes successfully, but no visible
|
|
666
|
-
* channel/thread reply ever surfaces to the user.
|
|
667
|
-
*
|
|
668
|
-
* Returns a structured violation when the outcome is `"empty"` for a payload
|
|
669
|
-
* that nominally carried user-facing content (text or media bytes that ended
|
|
670
|
-
* up dropped by `resolveSendableOutboundReplyParts`/`sendMediaWithLeadingCaption`).
|
|
671
|
-
* Returns `null` for `"reasoning_skipped"` (intentional suppression),
|
|
672
|
-
* `"text"`, or `"media"` (successful visible sends).
|
|
673
|
-
*/
|
|
505
|
+
/** Detect dropped substantive payloads even when the agent run succeeded (#80501). */
|
|
674
506
|
function evaluateMattermostNoVisibleReply(params) {
|
|
675
507
|
if (params.outcome !== "empty") return null;
|
|
676
508
|
const finalText = typeof params.payload.text === "string" ? params.payload.text.trim() : "";
|
|
@@ -691,9 +523,6 @@ function formatMattermostNoVisibleReplyLog(params) {
|
|
|
691
523
|
function shouldUpdateMattermostDraftToolProgress(account) {
|
|
692
524
|
return account.streamingMode !== "off" && resolveChannelStreamingPreviewToolProgress(account.config, account.streamingMode !== "progress", account.streamingMode);
|
|
693
525
|
}
|
|
694
|
-
function shouldSuppressMattermostDefaultToolProgressMessages(account) {
|
|
695
|
-
return account.streamingMode !== "off";
|
|
696
|
-
}
|
|
697
526
|
function buildMattermostModelPickerSelectMessageSid(params) {
|
|
698
527
|
const provider = normalizeLowercaseStringOrEmpty(params.provider);
|
|
699
528
|
const model = normalizeLowercaseStringOrEmpty(params.model);
|
|
@@ -753,9 +582,10 @@ function resolveMattermostThreadSessionContext(params) {
|
|
|
753
582
|
replyToMode: params.replyToMode,
|
|
754
583
|
threadRootId: params.threadRootId
|
|
755
584
|
});
|
|
756
|
-
const threadKeys = resolveThreadSessionKeys
|
|
585
|
+
const threadKeys = resolveThreadSessionKeys({
|
|
757
586
|
baseSessionKey: params.baseSessionKey,
|
|
758
587
|
threadId: effectiveReplyToId,
|
|
588
|
+
normalizeThreadId: (threadId) => threadId,
|
|
759
589
|
parentSessionKey: effectiveReplyToId && params.kind !== "direct" ? params.baseSessionKey : void 0
|
|
760
590
|
});
|
|
761
591
|
return {
|
|
@@ -917,7 +747,7 @@ function createMattermostQuestionInteractionHandler(monitor) {
|
|
|
917
747
|
}
|
|
918
748
|
function registerMattermostInteractions(params) {
|
|
919
749
|
const { monitor } = params;
|
|
920
|
-
const { account,
|
|
750
|
+
const { account, cfg, client, core, pairing, resources, runtime } = monitor;
|
|
921
751
|
const { resolveChannelInfo } = resources;
|
|
922
752
|
const handleQuestionInteraction = createMattermostQuestionInteractionHandler(monitor);
|
|
923
753
|
return registerPluginHttpRoute({
|
|
@@ -926,7 +756,6 @@ function registerMattermostInteractions(params) {
|
|
|
926
756
|
auth: "plugin",
|
|
927
757
|
handler: createMattermostInteractionHandler({
|
|
928
758
|
client,
|
|
929
|
-
botUserId,
|
|
930
759
|
accountId: account.accountId,
|
|
931
760
|
allowedSourceIps: params.allowedSourceIps,
|
|
932
761
|
trustedProxies: cfg.gateway?.trustedProxies,
|
|
@@ -1179,32 +1008,22 @@ function createMattermostModelPickerInteractionHandler(monitor) {
|
|
|
1179
1008
|
buttons
|
|
1180
1009
|
});
|
|
1181
1010
|
if (data.providers.length === 0) return await updatePickerPost("No models available.");
|
|
1182
|
-
if (pickerState.action
|
|
1011
|
+
if (pickerState.action !== "select") {
|
|
1183
1012
|
const currentModel = resolveMattermostModelPickerCurrentModel({
|
|
1184
1013
|
cfg,
|
|
1185
1014
|
route: modelSessionRoute,
|
|
1186
1015
|
data
|
|
1187
1016
|
});
|
|
1188
|
-
const
|
|
1017
|
+
const viewParams = {
|
|
1189
1018
|
ownerUserId: pickerState.ownerUserId,
|
|
1190
1019
|
data,
|
|
1191
1020
|
currentModel
|
|
1192
|
-
}
|
|
1193
|
-
|
|
1194
|
-
|
|
1195
|
-
if (pickerState.action === "list") {
|
|
1196
|
-
const currentModel = resolveMattermostModelPickerCurrentModel({
|
|
1197
|
-
cfg,
|
|
1198
|
-
route: modelSessionRoute,
|
|
1199
|
-
data
|
|
1200
|
-
});
|
|
1201
|
-
const view = renderMattermostModelsPickerView({
|
|
1202
|
-
ownerUserId: pickerState.ownerUserId,
|
|
1203
|
-
data,
|
|
1021
|
+
};
|
|
1022
|
+
const view = pickerState.action === "list" ? renderMattermostModelsPickerView({
|
|
1023
|
+
...viewParams,
|
|
1204
1024
|
provider: pickerState.provider,
|
|
1205
|
-
page: pickerState.page
|
|
1206
|
-
|
|
1207
|
-
});
|
|
1025
|
+
page: pickerState.page
|
|
1026
|
+
}) : renderMattermostProviderPickerView(viewParams);
|
|
1208
1027
|
return await updatePickerPost(view.text, view.buttons);
|
|
1209
1028
|
}
|
|
1210
1029
|
const targetModelRef = `${pickerState.provider}/${pickerState.model}`;
|
|
@@ -1244,6 +1063,18 @@ function createMattermostModelPickerInteractionHandler(monitor) {
|
|
|
1244
1063
|
};
|
|
1245
1064
|
}
|
|
1246
1065
|
//#endregion
|
|
1066
|
+
//#region src/channels/mention-gating.ts
|
|
1067
|
+
function resolveBotThreadMentionPolicy(params) {
|
|
1068
|
+
if (!params.isBotOwnedThread || params.requireMentionInBotThreads === void 0) return {
|
|
1069
|
+
requireMention: params.requireMention,
|
|
1070
|
+
implicitMentionKinds: params.implicitMentionKinds
|
|
1071
|
+
};
|
|
1072
|
+
return {
|
|
1073
|
+
requireMention: params.requireMentionInBotThreads,
|
|
1074
|
+
implicitMentionKinds: params.requireMentionInBotThreads ? params.implicitMentionKinds?.filter((kind) => kind === "native") : params.implicitMentionKinds
|
|
1075
|
+
};
|
|
1076
|
+
}
|
|
1077
|
+
//#endregion
|
|
1247
1078
|
//#region extensions/mattermost/src/mattermost/monitor-activation.ts
|
|
1248
1079
|
function resolveMattermostInboundMentionDecision(params) {
|
|
1249
1080
|
const implicitMentions = resolveChannelImplicitMentions({
|
|
@@ -1318,30 +1149,39 @@ function formatMattermostInboundMediaText(params) {
|
|
|
1318
1149
|
}
|
|
1319
1150
|
const CHANNEL_CACHE_TTL_MS = 3e5;
|
|
1320
1151
|
const USER_CACHE_TTL_MS = 6e5;
|
|
1152
|
+
const POST_CACHE_TTL_MS = 3e5;
|
|
1321
1153
|
const MONITOR_RESOURCE_CACHE_MAX_ENTRIES = 1e3;
|
|
1322
1154
|
const MATTERMOST_MEDIA_RESPONSE_HEADER_TIMEOUT_MS = 12e4;
|
|
1323
1155
|
const MATTERMOST_MEDIA_READ_IDLE_TIMEOUT_MS = 3e4;
|
|
1324
1156
|
function createMattermostMonitorResources(params) {
|
|
1325
1157
|
const { accountId, callbackUrl, client, logger, mediaMaxBytes, saveRemoteMedia, mediaKindFromMime } = params;
|
|
1326
|
-
|
|
1327
|
-
|
|
1328
|
-
|
|
1329
|
-
|
|
1330
|
-
|
|
1331
|
-
|
|
1332
|
-
|
|
1333
|
-
|
|
1334
|
-
|
|
1335
|
-
|
|
1336
|
-
|
|
1337
|
-
|
|
1338
|
-
|
|
1339
|
-
|
|
1340
|
-
|
|
1341
|
-
|
|
1342
|
-
|
|
1343
|
-
|
|
1344
|
-
|
|
1158
|
+
function createCachedLookup(label, ttlMs, fetchValue) {
|
|
1159
|
+
const cache = /* @__PURE__ */ new Map();
|
|
1160
|
+
return async (id) => {
|
|
1161
|
+
const rawNow = Date.now();
|
|
1162
|
+
const now = asDateTimestampMs(rawNow);
|
|
1163
|
+
const cached = cache.get(id);
|
|
1164
|
+
if (cached && now !== void 0 && cached.expiresAt > now) {
|
|
1165
|
+
if (cached.value !== void 0) return cached.value;
|
|
1166
|
+
} else cache.delete(id);
|
|
1167
|
+
try {
|
|
1168
|
+
const value = await fetchValue(id);
|
|
1169
|
+
const expiresAt = resolveExpiresAtMsFromDurationMs(ttlMs, { nowMs: rawNow });
|
|
1170
|
+
if (expiresAt !== void 0) {
|
|
1171
|
+
cache.delete(id);
|
|
1172
|
+
cache.set(id, {
|
|
1173
|
+
value,
|
|
1174
|
+
expiresAt
|
|
1175
|
+
});
|
|
1176
|
+
pruneMapToMaxSize(cache, MONITOR_RESOURCE_CACHE_MAX_ENTRIES);
|
|
1177
|
+
}
|
|
1178
|
+
return value;
|
|
1179
|
+
} catch (err) {
|
|
1180
|
+
logger.debug?.(`mattermost: ${label} lookup failed: ${String(err)}`);
|
|
1181
|
+
return null;
|
|
1182
|
+
}
|
|
1183
|
+
};
|
|
1184
|
+
}
|
|
1345
1185
|
const resolveMattermostMedia = async (fileIds) => {
|
|
1346
1186
|
const ids = normalizeStringEntries(fileIds ?? []);
|
|
1347
1187
|
if (ids.length === 0) return [];
|
|
@@ -1397,40 +1237,20 @@ function createMattermostMonitorResources(params) {
|
|
|
1397
1237
|
parentId
|
|
1398
1238
|
});
|
|
1399
1239
|
};
|
|
1400
|
-
const resolveChannelInfo =
|
|
1401
|
-
|
|
1402
|
-
|
|
1403
|
-
|
|
1404
|
-
|
|
1405
|
-
|
|
1406
|
-
setCachedValue(channelCache, channelId, info, CHANNEL_CACHE_TTL_MS, rawNow);
|
|
1407
|
-
return info;
|
|
1408
|
-
} catch (err) {
|
|
1409
|
-
logger.debug?.(`mattermost: channel lookup failed: ${String(err)}`);
|
|
1410
|
-
return null;
|
|
1411
|
-
}
|
|
1412
|
-
};
|
|
1413
|
-
const resolveUserInfo = async (userId) => {
|
|
1414
|
-
const rawNow = Date.now();
|
|
1415
|
-
const cached = getCachedValue(userCache, userId, asDateTimestampMs(rawNow));
|
|
1416
|
-
if (cached !== void 0) return cached;
|
|
1417
|
-
try {
|
|
1418
|
-
const info = await fetchMattermostUser(client, userId);
|
|
1419
|
-
setCachedValue(userCache, userId, info, USER_CACHE_TTL_MS, rawNow);
|
|
1420
|
-
return info;
|
|
1421
|
-
} catch (err) {
|
|
1422
|
-
logger.debug?.(`mattermost: user lookup failed: ${String(err)}`);
|
|
1423
|
-
return null;
|
|
1424
|
-
}
|
|
1425
|
-
};
|
|
1426
|
-
const buildModelPickerProps = (channelId, buttons) => buildButtonProps({
|
|
1427
|
-
callbackUrl,
|
|
1428
|
-
accountId,
|
|
1429
|
-
channelId,
|
|
1430
|
-
buttons
|
|
1240
|
+
const resolveChannelInfo = createCachedLookup("channel", CHANNEL_CACHE_TTL_MS, (channelId) => fetchMattermostChannel(client, channelId));
|
|
1241
|
+
const resolveUserInfo = createCachedLookup("user", USER_CACHE_TTL_MS, (userId) => fetchMattermostUser(client, userId));
|
|
1242
|
+
const resolvePostInfo = createCachedLookup("post", POST_CACHE_TTL_MS, async (postId) => {
|
|
1243
|
+
const info = MattermostPostSchema.parse(await client.request(`/posts/${encodeURIComponent(postId)}`));
|
|
1244
|
+
if (info.id !== postId) throw new Error("Mattermost post lookup returned a different post id");
|
|
1245
|
+
return info;
|
|
1431
1246
|
});
|
|
1432
1247
|
const updateModelPickerPost = async (paramsLocal) => {
|
|
1433
|
-
const props =
|
|
1248
|
+
const props = buildButtonProps({
|
|
1249
|
+
callbackUrl,
|
|
1250
|
+
accountId,
|
|
1251
|
+
channelId: paramsLocal.channelId,
|
|
1252
|
+
buttons: paramsLocal.buttons ?? []
|
|
1253
|
+
}) ?? { attachments: [] };
|
|
1434
1254
|
await updateMattermostPost(client, paramsLocal.postId, {
|
|
1435
1255
|
message: paramsLocal.message,
|
|
1436
1256
|
props
|
|
@@ -1442,6 +1262,7 @@ function createMattermostMonitorResources(params) {
|
|
|
1442
1262
|
sendTypingIndicator,
|
|
1443
1263
|
resolveChannelInfo,
|
|
1444
1264
|
resolveUserInfo,
|
|
1265
|
+
resolvePostInfo,
|
|
1445
1266
|
updateModelPickerPost
|
|
1446
1267
|
};
|
|
1447
1268
|
}
|
|
@@ -1730,21 +1551,16 @@ function createMattermostDraftStream(params) {
|
|
|
1730
1551
|
return false;
|
|
1731
1552
|
}
|
|
1732
1553
|
};
|
|
1733
|
-
const clearMessageId = () => {
|
|
1734
|
-
currentGeneration.postId = void 0;
|
|
1735
|
-
};
|
|
1736
|
-
const isValidMessageId = (value) => typeof value === "string" && value.length > 0;
|
|
1737
|
-
const deleteMessage = async (postId) => {
|
|
1738
|
-
await deleteMattermostPost(params.client, postId);
|
|
1739
|
-
};
|
|
1740
1554
|
const { loop, update: updateLifecycle, stop: stopLifecycle, stopForClear, clearWithStop, seal: sealLifecycle } = createFinalizableDraftLifecycle({
|
|
1741
1555
|
throttleMs,
|
|
1742
1556
|
state: streamState,
|
|
1743
1557
|
sendOrEditStreamMessage,
|
|
1744
1558
|
readMessageId: () => currentGeneration.postId,
|
|
1745
|
-
clearMessageId
|
|
1746
|
-
|
|
1747
|
-
|
|
1559
|
+
clearMessageId: () => {
|
|
1560
|
+
currentGeneration.postId = void 0;
|
|
1561
|
+
},
|
|
1562
|
+
isValidMessageId: (value) => typeof value === "string" && value.length > 0,
|
|
1563
|
+
deleteMessage: (postId) => deleteMattermostPost(params.client, postId),
|
|
1748
1564
|
warn: params.warn,
|
|
1749
1565
|
warnPrefix: "mattermost stream preview cleanup failed"
|
|
1750
1566
|
});
|
|
@@ -1834,18 +1650,13 @@ function createMattermostDraftStream(params) {
|
|
|
1834
1650
|
loop.resetThrottleWindow();
|
|
1835
1651
|
return boundary;
|
|
1836
1652
|
};
|
|
1837
|
-
const
|
|
1653
|
+
const settleOperation = (operation) => async () => {
|
|
1838
1654
|
assertNoAcceptedDeliveryFailure();
|
|
1839
|
-
await
|
|
1840
|
-
await currentGeneration.ready;
|
|
1841
|
-
assertNoAcceptedDeliveryFailure();
|
|
1842
|
-
};
|
|
1843
|
-
const discardPending = async () => {
|
|
1844
|
-
assertNoAcceptedDeliveryFailure();
|
|
1845
|
-
await stopForClear();
|
|
1655
|
+
await operation();
|
|
1846
1656
|
await currentGeneration.ready;
|
|
1847
1657
|
assertNoAcceptedDeliveryFailure();
|
|
1848
1658
|
};
|
|
1659
|
+
const discardPending = settleOperation(stopForClear);
|
|
1849
1660
|
const clear = async () => {
|
|
1850
1661
|
assertNoAcceptedDeliveryFailure();
|
|
1851
1662
|
await clearWithStop(discardPending);
|
|
@@ -1875,18 +1686,6 @@ function createMattermostDraftStream(params) {
|
|
|
1875
1686
|
await retirement;
|
|
1876
1687
|
assertNoAcceptedDeliveryFailure();
|
|
1877
1688
|
};
|
|
1878
|
-
const seal = async () => {
|
|
1879
|
-
assertNoAcceptedDeliveryFailure();
|
|
1880
|
-
await sealLifecycle();
|
|
1881
|
-
await currentGeneration.ready;
|
|
1882
|
-
assertNoAcceptedDeliveryFailure();
|
|
1883
|
-
};
|
|
1884
|
-
const stop = async () => {
|
|
1885
|
-
assertNoAcceptedDeliveryFailure();
|
|
1886
|
-
await stopLifecycle();
|
|
1887
|
-
await currentGeneration.ready;
|
|
1888
|
-
assertNoAcceptedDeliveryFailure();
|
|
1889
|
-
};
|
|
1890
1689
|
const update = (text) => {
|
|
1891
1690
|
currentGeneration.latestSourceText = text;
|
|
1892
1691
|
currentGeneration.latestAssistantText = void 0;
|
|
@@ -1945,13 +1744,13 @@ function createMattermostDraftStream(params) {
|
|
|
1945
1744
|
return {
|
|
1946
1745
|
update,
|
|
1947
1746
|
updateAssistantText,
|
|
1948
|
-
flush,
|
|
1747
|
+
flush: settleOperation(loop.flush),
|
|
1949
1748
|
postId: () => currentGeneration.postId,
|
|
1950
1749
|
clear,
|
|
1951
1750
|
deleteCurrentMessage,
|
|
1952
1751
|
discardPending,
|
|
1953
|
-
seal,
|
|
1954
|
-
stop,
|
|
1752
|
+
seal: settleOperation(sealLifecycle),
|
|
1753
|
+
stop: settleOperation(stopLifecycle),
|
|
1955
1754
|
forceNewMessage,
|
|
1956
1755
|
settleBoundaries,
|
|
1957
1756
|
resolveFinalText
|
|
@@ -1959,11 +1758,11 @@ function createMattermostDraftStream(params) {
|
|
|
1959
1758
|
}
|
|
1960
1759
|
//#endregion
|
|
1961
1760
|
//#region extensions/mattermost/src/mattermost/monitor-draft-delivery.ts
|
|
1962
|
-
function combineMattermostVisibleDeliveryResults(results) {
|
|
1761
|
+
function combineMattermostVisibleDeliveryResults(results, outcome) {
|
|
1963
1762
|
const visibleResults = results.filter((result) => result?.visibleReplySent === true);
|
|
1964
1763
|
if (visibleResults.length === 0) return;
|
|
1965
1764
|
return {
|
|
1966
|
-
outcome
|
|
1765
|
+
outcome,
|
|
1967
1766
|
...createAcceptedChannelDeliveryResult({
|
|
1968
1767
|
deliveryResults: visibleResults,
|
|
1969
1768
|
content: joinMattermostVisibleContent(visibleResults.map((result) => result.content))
|
|
@@ -1976,35 +1775,30 @@ async function deliverMattermostReplyWithDraftPreview(params) {
|
|
|
1976
1775
|
visibleReplySent: false,
|
|
1977
1776
|
suppression: { reason: "no_visible_result" }
|
|
1978
1777
|
};
|
|
1979
|
-
let
|
|
1980
|
-
|
|
1981
|
-
|
|
1982
|
-
|
|
1983
|
-
|
|
1984
|
-
let previewFinalTextAlreadyDelivered =
|
|
1985
|
-
|
|
1986
|
-
|
|
1987
|
-
|
|
1778
|
+
let outcome = "text";
|
|
1779
|
+
const ttsSupplement = getReplyPayloadTtsSupplement(params.payload);
|
|
1780
|
+
const previewFinalResolution = params.info.kind === "final" && !params.previewLifecycle.previewFinalized ? params.resolvePreviewFinalText(params.payload.text ?? ttsSupplement?.spokenText) : void 0;
|
|
1781
|
+
const confirmedPreviewDelivery = previewFinalResolution?.confirmedDelivery;
|
|
1782
|
+
const previewFinalDeliveryText = previewFinalResolution?.deliveryText;
|
|
1783
|
+
let previewFinalTextAlreadyDelivered = previewFinalResolution?.alreadyDelivered === true && params.payload.isError !== true;
|
|
1784
|
+
if (previewFinalTextAlreadyDelivered && !resolveSendableOutboundReplyParts(params.payload).hasMedia && !params.payload.presentation && confirmedPreviewDelivery?.visibleReplySent) try {
|
|
1785
|
+
await params.previewLifecycle.observeDelivery(confirmedPreviewDelivery);
|
|
1786
|
+
await params.recordThreadParticipation?.();
|
|
1787
|
+
return confirmedPreviewDelivery;
|
|
1788
|
+
} catch (error) {
|
|
1789
|
+
throw createChannelPartialDeliveryError(error, {
|
|
1790
|
+
...confirmedPreviewDelivery,
|
|
1791
|
+
visibleReplySent: true
|
|
1792
|
+
});
|
|
1793
|
+
}
|
|
1988
1794
|
try {
|
|
1989
|
-
|
|
1795
|
+
return combineMattermostVisibleDeliveryResults([confirmedPreviewDelivery, (await params.previewLifecycle.deliver({
|
|
1990
1796
|
kind: params.info.kind,
|
|
1991
1797
|
payload: params.payload,
|
|
1992
|
-
|
|
1993
|
-
|
|
1994
|
-
flush: params.draftStream.flush,
|
|
1995
|
-
clear: params.draftStream.clear,
|
|
1996
|
-
discardPending: params.draftStream.discardPending,
|
|
1997
|
-
seal: params.draftStream.seal,
|
|
1998
|
-
id: params.draftStream.postId
|
|
1999
|
-
} },
|
|
1798
|
+
isError: params.payload.isError,
|
|
1799
|
+
adapter: {
|
|
2000
1800
|
buildFinalEdit: (payload) => {
|
|
2001
1801
|
const hasMedia = Boolean(payload.mediaUrl) || (payload.mediaUrls?.length ?? 0) > 0;
|
|
2002
|
-
const ttsSupplement = getReplyPayloadTtsSupplement(payload);
|
|
2003
|
-
const previewFinalResolution = params.resolvePreviewFinalText(payload.text ?? ttsSupplement?.spokenText);
|
|
2004
|
-
confirmedPreviewDelivery = previewFinalResolution?.confirmedDelivery;
|
|
2005
|
-
previewFinalDeliveryText = previewFinalResolution?.deliveryText;
|
|
2006
|
-
previewFinalTextAlreadyDelivered = previewFinalResolution?.alreadyDelivered === true && payload.isError !== true;
|
|
2007
|
-
useConfirmedPreviewAsWholeFinal = previewFinalTextAlreadyDelivered && !resolveSendableOutboundReplyParts(payload).hasMedia && !payload.presentation;
|
|
2008
1802
|
const previewFinalText = previewFinalResolution?.editText;
|
|
2009
1803
|
if (hasMedia && !ttsSupplement || typeof previewFinalText !== "string" || payload.isError || payload.presentation || !canFinalizeMattermostPreviewInPlace({
|
|
2010
1804
|
kind: params.kind,
|
|
@@ -2012,36 +1806,33 @@ async function deliverMattermostReplyWithDraftPreview(params) {
|
|
|
2012
1806
|
threadRootId: params.effectiveReplyToId,
|
|
2013
1807
|
replyToId: payload.replyToId
|
|
2014
1808
|
})) return;
|
|
2015
|
-
pendingPreviewFinalContent = previewFinalText;
|
|
2016
1809
|
return { message: previewFinalText };
|
|
2017
1810
|
},
|
|
2018
1811
|
editFinal: async (previewPostId, edit) => {
|
|
2019
|
-
|
|
2020
|
-
|
|
2021
|
-
|
|
2022
|
-
|
|
2023
|
-
params.previewState.finalizedViaPreviewPost = true;
|
|
2024
|
-
previewFinalTextAlreadyDelivered = true;
|
|
2025
|
-
previewDeliveryResult = {
|
|
2026
|
-
outcome: "text",
|
|
2027
|
-
messageIds: listMessageReceiptPlatformIds(receipt),
|
|
1812
|
+
const post = await updateMattermostPost(params.client, previewPostId, edit);
|
|
1813
|
+
const receipt = createPreviewMessageReceipt({ id: post.id ?? previewPostId });
|
|
1814
|
+
return {
|
|
1815
|
+
messageIds: receipt.platformMessageIds,
|
|
2028
1816
|
receipt,
|
|
2029
1817
|
visibleReplySent: true,
|
|
2030
|
-
content:
|
|
1818
|
+
content: post.message ?? edit.message
|
|
2031
1819
|
};
|
|
1820
|
+
},
|
|
1821
|
+
onPreviewFinalized: async () => {
|
|
1822
|
+
previewFinalTextAlreadyDelivered = true;
|
|
2032
1823
|
await params.recordThreadParticipation?.();
|
|
2033
1824
|
},
|
|
2034
1825
|
buildSupplementalPayload: (payload) => getReplyPayloadTtsSupplement(payload) ? buildTtsSupplementMediaPayload(payload) : void 0,
|
|
2035
1826
|
deliverSupplemental: async (payload) => {
|
|
2036
|
-
|
|
2037
|
-
|
|
1827
|
+
const delivered = await params.deliverPayload(payload);
|
|
1828
|
+
if (delivered.outcome === "media") outcome = "media";
|
|
1829
|
+
return delivered.visibleReplySent ? delivered : false;
|
|
2038
1830
|
},
|
|
2039
1831
|
logPreviewEditFailure: (err) => {
|
|
2040
1832
|
params.logVerboseMessage(`mattermost preview final edit failed; falling back to normal send (${String(err)})`);
|
|
2041
1833
|
}
|
|
2042
|
-
}
|
|
1834
|
+
},
|
|
2043
1835
|
deliverNormally: async (payload) => {
|
|
2044
|
-
if (useConfirmedPreviewAsWholeFinal && confirmedPreviewDelivery?.visibleReplySent === true) return true;
|
|
2045
1836
|
const supplement = getReplyPayloadTtsSupplement(payload);
|
|
2046
1837
|
const resolvedDeliveryText = previewFinalDeliveryText ?? (previewFinalTextAlreadyDelivered ? "" : void 0);
|
|
2047
1838
|
const payloadText = payload.text?.trim();
|
|
@@ -2052,38 +1843,22 @@ async function deliverMattermostReplyWithDraftPreview(params) {
|
|
|
2052
1843
|
...payload,
|
|
2053
1844
|
text: resolvedDeliveryText
|
|
2054
1845
|
} : payload;
|
|
2055
|
-
|
|
2056
|
-
|
|
2057
|
-
|
|
2058
|
-
|
|
1846
|
+
const delivered = await params.deliverPayload(deliveryPayload);
|
|
1847
|
+
if (delivered.outcome === "media") outcome = "media";
|
|
1848
|
+
return delivered;
|
|
1849
|
+
},
|
|
1850
|
+
onNormalDelivered: params.recordThreadParticipation
|
|
1851
|
+
})).deliveryResult], outcome) ?? {
|
|
2059
1852
|
outcome: "empty",
|
|
2060
1853
|
visibleReplySent: false,
|
|
2061
1854
|
suppression: { reason: "no_visible_result" }
|
|
2062
1855
|
};
|
|
2063
|
-
return combineMattermostVisibleDeliveryResults([
|
|
2064
|
-
confirmedPreviewDelivery,
|
|
2065
|
-
previewDeliveryResult,
|
|
2066
|
-
supplementalDeliveryResult,
|
|
2067
|
-
normalDeliveryResult
|
|
2068
|
-
]) ?? previewDeliveryResult;
|
|
2069
1856
|
} catch (error) {
|
|
2070
|
-
|
|
2071
|
-
confirmedPreviewDelivery,
|
|
2072
|
-
previewDeliveryResult,
|
|
2073
|
-
normalDeliveryResult,
|
|
2074
|
-
supplementalDeliveryResult
|
|
2075
|
-
].filter((result) => result?.visibleReplySent === true);
|
|
2076
|
-
if (completedVisibleResults.length === 0) throw error;
|
|
1857
|
+
if (!confirmedPreviewDelivery?.visibleReplySent) throw error;
|
|
2077
1858
|
const failedPartial = isChannelPartialDeliveryError(error) ? error.deliveryResult : void 0;
|
|
2078
1859
|
throw createChannelPartialDeliveryError(error, createAcceptedChannelDeliveryResult({
|
|
2079
|
-
deliveryResults: [
|
|
2080
|
-
content: joinMattermostVisibleContent([
|
|
2081
|
-
confirmedPreviewDelivery?.content,
|
|
2082
|
-
previewDeliveryResult?.content,
|
|
2083
|
-
normalDeliveryResult?.content,
|
|
2084
|
-
supplementalDeliveryResult?.content,
|
|
2085
|
-
failedPartial?.content
|
|
2086
|
-
])
|
|
1860
|
+
deliveryResults: [confirmedPreviewDelivery, ...failedPartial ? [failedPartial] : []],
|
|
1861
|
+
content: joinMattermostVisibleContent([confirmedPreviewDelivery.content, failedPartial?.content])
|
|
2087
1862
|
}));
|
|
2088
1863
|
}
|
|
2089
1864
|
}
|
|
@@ -2155,7 +1930,6 @@ async function dispatchMattermostInboundTurn(monitor, params) {
|
|
|
2155
1930
|
const hookRunner = getGlobalHookRunner();
|
|
2156
1931
|
const draftPreviewEnabled = !((hookRunner?.hasHooks("reply_payload_sending") ?? false) || (hookRunner?.hasHooks("message_sending") ?? false)) && account.streamingMode !== "off";
|
|
2157
1932
|
const draftProgressEnabled = draftPreviewEnabled && (account.streamingMode === "progress" || shouldUpdateMattermostDraftToolProgress(account));
|
|
2158
|
-
const suppressDefaultToolProgressMessages = draftPreviewEnabled && shouldSuppressMattermostDefaultToolProgressMessages(account);
|
|
2159
1933
|
const draftStream = draftPreviewEnabled ? createMattermostDraftStream({
|
|
2160
1934
|
client,
|
|
2161
1935
|
channelId,
|
|
@@ -2167,9 +1941,7 @@ async function dispatchMattermostInboundTurn(monitor, params) {
|
|
|
2167
1941
|
}) : createDisabledMattermostDraftStream();
|
|
2168
1942
|
const previewBoundaryController = createMattermostDraftPreviewBoundaryController({
|
|
2169
1943
|
enabled: draftPreviewEnabled && account.streamingMode === "block",
|
|
2170
|
-
forceNewMessage:
|
|
2171
|
-
await draftStream.forceNewMessage();
|
|
2172
|
-
}
|
|
1944
|
+
forceNewMessage: draftStream.forceNewMessage
|
|
2173
1945
|
});
|
|
2174
1946
|
let lastPartialText = "";
|
|
2175
1947
|
let firstAssistantPreviewPrefix;
|
|
@@ -2178,6 +1950,7 @@ async function dispatchMattermostInboundTurn(monitor, params) {
|
|
|
2178
1950
|
let blockPreviewActivity = "none";
|
|
2179
1951
|
let blockPreviewAssistantMessagePending = false;
|
|
2180
1952
|
const progressDraft = createChannelProgressDraftCompositor({
|
|
1953
|
+
preparedItems: true,
|
|
2181
1954
|
entry: account.config,
|
|
2182
1955
|
mode: account.streamingMode,
|
|
2183
1956
|
active: draftPreviewEnabled,
|
|
@@ -2201,7 +1974,18 @@ async function dispatchMattermostInboundTurn(monitor, params) {
|
|
|
2201
1974
|
if (activity === "tool") lastPartialText = "";
|
|
2202
1975
|
return boundarySettled;
|
|
2203
1976
|
};
|
|
2204
|
-
const
|
|
1977
|
+
const previewLifecycle = createLivePreviewLifecycle({
|
|
1978
|
+
draft: draftPreviewEnabled ? {
|
|
1979
|
+
flush: draftStream.flush,
|
|
1980
|
+
id: draftStream.postId,
|
|
1981
|
+
seal: draftStream.seal,
|
|
1982
|
+
discardPending: draftStream.discardPending,
|
|
1983
|
+
clear: draftStream.clear
|
|
1984
|
+
} : void 0,
|
|
1985
|
+
onFinalStarted: () => progressDraft.markFinalReplyStarted(),
|
|
1986
|
+
onFinalDelivered: () => progressDraft.markFinalReplyDelivered(),
|
|
1987
|
+
onCleanupFailure: (err) => monitor.logVerboseMessage(`mattermost draft preview cleanup failed: ${String(err)}`)
|
|
1988
|
+
});
|
|
2205
1989
|
const resolvePreviewFinalText = (text) => {
|
|
2206
1990
|
const resolution = draftStream.resolveFinalText(typeof text === "string" ? text : "");
|
|
2207
1991
|
const confirmedDelivery = resolution.publishedParts.length > 0 ? (() => {
|
|
@@ -2226,12 +2010,7 @@ async function dispatchMattermostInboundTurn(monitor, params) {
|
|
|
2226
2010
|
const formatted = core.channel.text.convertMarkdownTables(deliveryText, tableMode);
|
|
2227
2011
|
const chunks = core.channel.text.chunkMarkdownTextWithMode(formatted, textLimit, chunkMode);
|
|
2228
2012
|
if (!chunks.length && formatted) chunks.push(formatted);
|
|
2229
|
-
|
|
2230
|
-
deliveryText,
|
|
2231
|
-
confirmedDelivery,
|
|
2232
|
-
alreadyDelivered: resolution.kind === "already-delivered"
|
|
2233
|
-
};
|
|
2234
|
-
const trimmed = chunks[0]?.trim();
|
|
2013
|
+
const trimmed = chunks.length === 1 ? chunks[0]?.trim() : void 0;
|
|
2235
2014
|
if (!trimmed) return {
|
|
2236
2015
|
deliveryText,
|
|
2237
2016
|
confirmedDelivery,
|
|
@@ -2277,7 +2056,6 @@ async function dispatchMattermostInboundTurn(monitor, params) {
|
|
|
2277
2056
|
if (info.kind === "final") {
|
|
2278
2057
|
await enterBlockPreviewActivity("text");
|
|
2279
2058
|
await draftStream.settleBoundaries();
|
|
2280
|
-
progressDraft.markFinalReplyStarted();
|
|
2281
2059
|
}
|
|
2282
2060
|
let threadParticipationRecorded = false;
|
|
2283
2061
|
const markThreadParticipation = async () => {
|
|
@@ -2291,10 +2069,9 @@ async function dispatchMattermostInboundTurn(monitor, params) {
|
|
|
2291
2069
|
info,
|
|
2292
2070
|
kind,
|
|
2293
2071
|
client,
|
|
2294
|
-
|
|
2072
|
+
previewLifecycle,
|
|
2295
2073
|
effectiveReplyToId,
|
|
2296
2074
|
resolvePreviewFinalText,
|
|
2297
|
-
previewState,
|
|
2298
2075
|
logVerboseMessage: monitor.logVerboseMessage,
|
|
2299
2076
|
recordThreadParticipation: markThreadParticipation,
|
|
2300
2077
|
deliverPayload: async (payloadToDeliver) => {
|
|
@@ -2318,12 +2095,7 @@ async function dispatchMattermostInboundTurn(monitor, params) {
|
|
|
2318
2095
|
textLimit,
|
|
2319
2096
|
tableMode,
|
|
2320
2097
|
sendMessage: sendMessageMattermost
|
|
2321
|
-
}).catch(async (error) => {
|
|
2322
|
-
if (isChannelPartialDeliveryError(error)) await markThreadParticipation();
|
|
2323
|
-
throw error;
|
|
2324
2098
|
});
|
|
2325
|
-
if (deliveryResult.outcome === "text" || deliveryResult.outcome === "media") await markThreadParticipation();
|
|
2326
|
-
else if (deliveryResult.outcome === "empty" && finalTextResolution?.kind === "already-delivered") await markThreadParticipation();
|
|
2327
2099
|
const deliveryLog = formatMattermostFinalDeliveryOutcomeLog({
|
|
2328
2100
|
outcome: deliveryResult.outcome,
|
|
2329
2101
|
payload: resolvedPayload,
|
|
@@ -2335,14 +2107,10 @@ async function dispatchMattermostInboundTurn(monitor, params) {
|
|
|
2335
2107
|
return deliveryResult;
|
|
2336
2108
|
}
|
|
2337
2109
|
}).catch(async (error) => {
|
|
2338
|
-
if (isChannelPartialDeliveryError(error))
|
|
2339
|
-
await markThreadParticipation();
|
|
2340
|
-
if (info.kind === "final") progressDraft.markFinalReplyDelivered();
|
|
2341
|
-
}
|
|
2110
|
+
if (isChannelPartialDeliveryError(error)) await markThreadParticipation();
|
|
2342
2111
|
throw error;
|
|
2343
2112
|
});
|
|
2344
2113
|
if (result.visibleReplySent) await markThreadParticipation();
|
|
2345
|
-
if (info.kind === "final") progressDraft.markFinalReplyDelivered();
|
|
2346
2114
|
return result;
|
|
2347
2115
|
},
|
|
2348
2116
|
onError: (err, info) => {
|
|
@@ -2404,21 +2172,20 @@ async function dispatchMattermostInboundTurn(monitor, params) {
|
|
|
2404
2172
|
dispatcherOptions,
|
|
2405
2173
|
delivery,
|
|
2406
2174
|
replyOptions: {
|
|
2175
|
+
progressPreambleEnabled: draftProgressEnabled,
|
|
2176
|
+
commentaryProgressEnabled: progressDraft.commentaryProgressEnabled,
|
|
2407
2177
|
...turnAdoptionLifecycle ? bindIngressLifecycleToReplyOptions(turnAdoptionLifecycle) : {},
|
|
2408
2178
|
allowProgressCallbacksWhenSourceDeliverySuppressed: draftProgressEnabled ? true : void 0,
|
|
2409
2179
|
preserveProgressCallbackStartOrder: draftPreviewEnabled ? true : void 0,
|
|
2410
|
-
onObservedReplyDelivery:
|
|
2180
|
+
onObservedReplyDelivery: draftPreviewEnabled ? () => previewLifecycle.observeDelivery({ visibleReplySent: true }) : void 0,
|
|
2411
2181
|
disableBlockStreaming: draftPreviewEnabled ? true : replyOptions.disableBlockStreaming,
|
|
2412
|
-
...
|
|
2182
|
+
...draftPreviewEnabled ? { suppressDefaultToolProgressMessages: true } : {},
|
|
2413
2183
|
onModelSelected,
|
|
2414
2184
|
onPartialReply: (payloadResult) => account.streamingMode === "progress" ? false : updateDraftFromPartial(payloadResult.text),
|
|
2415
2185
|
onAssistantMessageStart: () => {
|
|
2416
2186
|
lastPartialText = "";
|
|
2417
2187
|
progressDraft.beginAssistantMessage();
|
|
2418
|
-
if (account.streamingMode === "block")
|
|
2419
|
-
blockPreviewAssistantMessagePending = true;
|
|
2420
|
-
return false;
|
|
2421
|
-
}
|
|
2188
|
+
if (account.streamingMode === "block") blockPreviewAssistantMessagePending = true;
|
|
2422
2189
|
return false;
|
|
2423
2190
|
},
|
|
2424
2191
|
onReasoningEnd: () => {
|
|
@@ -2447,23 +2214,10 @@ async function dispatchMattermostInboundTurn(monitor, params) {
|
|
|
2447
2214
|
const [, visible] = await Promise.all([boundarySettled, progressSettled]);
|
|
2448
2215
|
return visible;
|
|
2449
2216
|
},
|
|
2450
|
-
onToolStart:
|
|
2451
|
-
if (!draftProgressEnabled) return false;
|
|
2452
|
-
const boundarySettled = enterBlockPreviewActivity("tool");
|
|
2453
|
-
const progressSettled = progressDraft.pushToolProgress(buildChannelProgressDraftLineForEntry(account.config, {
|
|
2454
|
-
event: "tool",
|
|
2455
|
-
itemId: payloadValue.itemId,
|
|
2456
|
-
toolCallId: payloadValue.toolCallId,
|
|
2457
|
-
name: payloadValue.name,
|
|
2458
|
-
phase: payloadValue.phase,
|
|
2459
|
-
args: payloadValue.args
|
|
2460
|
-
}, payloadValue.detailMode ? { detailMode: payloadValue.detailMode } : void 0), { startImmediately: true });
|
|
2461
|
-
previewBoundaryController.noteUpdate();
|
|
2462
|
-
const [, visible] = await Promise.all([boundarySettled, progressSettled]);
|
|
2463
|
-
return visible;
|
|
2464
|
-
},
|
|
2217
|
+
onToolStart: (payload) => progressDraft.pushToolEvent(payload),
|
|
2465
2218
|
onItemEvent: async (payloadLocal) => {
|
|
2466
2219
|
if (!draftProgressEnabled) return false;
|
|
2220
|
+
if (payloadLocal.hideFromChannelProgress || payloadLocal.suppressChannelProgress) return progressDraft.pushItemEvent(payloadLocal);
|
|
2467
2221
|
const boundarySettled = enterBlockPreviewActivity("tool");
|
|
2468
2222
|
const progressSettled = progressDraft.pushItemEvent(payloadLocal);
|
|
2469
2223
|
previewBoundaryController.noteUpdate();
|
|
@@ -2477,6 +2231,7 @@ async function dispatchMattermostInboundTurn(monitor, params) {
|
|
|
2477
2231
|
} finally {
|
|
2478
2232
|
try {
|
|
2479
2233
|
await draftStream.stop();
|
|
2234
|
+
await previewLifecycle.cleanup();
|
|
2480
2235
|
} catch (err) {
|
|
2481
2236
|
monitor.logVerboseMessage(`mattermost draft preview cleanup failed: ${String(err)}`);
|
|
2482
2237
|
}
|
|
@@ -2486,15 +2241,16 @@ async function dispatchMattermostInboundTurn(monitor, params) {
|
|
|
2486
2241
|
//#region extensions/mattermost/src/mattermost/monitor-posts.ts
|
|
2487
2242
|
function createMattermostPostHandler(monitor) {
|
|
2488
2243
|
const { account, botUserId, botUsername, cfg, core, groupPolicy, pairing, resources } = monitor;
|
|
2244
|
+
const groups = resolveChannelGroups(cfg, "mattermost", account.accountId);
|
|
2489
2245
|
const groupsConfigPath = resolveChannelGroupsConfigPath({
|
|
2490
2246
|
cfg,
|
|
2491
2247
|
channel: "mattermost",
|
|
2492
2248
|
accountId: account.accountId,
|
|
2493
|
-
groups
|
|
2249
|
+
groups
|
|
2494
2250
|
});
|
|
2495
2251
|
const { resolveMattermostMedia, resolveUserInfo } = resources;
|
|
2496
2252
|
const channelHistories = /* @__PURE__ */ new Map();
|
|
2497
|
-
const historyLimit =
|
|
2253
|
+
const historyLimit = resolvePromptHistoryLimit(account.config.historyLimit ?? cfg.messages?.groupChat?.historyLimit, DEFAULT_GROUP_HISTORY_LIMIT);
|
|
2498
2254
|
const recoverThread = createMattermostThreadBackfill({
|
|
2499
2255
|
monitor,
|
|
2500
2256
|
channelHistories,
|
|
@@ -2673,14 +2429,30 @@ function createMattermostPostHandler(monitor) {
|
|
|
2673
2429
|
groupId: channelId,
|
|
2674
2430
|
requireMentionOverride: account.requireMention
|
|
2675
2431
|
});
|
|
2432
|
+
const requireMentionInBotThreads = groups?.[channelId]?.requireMentionInBotThreads ?? groups?.["*"]?.requireMentionInBotThreads ?? account.config.requireMentionInBotThreads;
|
|
2433
|
+
const nativeThreadRootId = normalizeOptionalString(post.root_id);
|
|
2434
|
+
let isBotOwnedThread = false;
|
|
2435
|
+
if (kind !== "direct" && nativeThreadRootId && requireMentionInBotThreads !== void 0) try {
|
|
2436
|
+
const root = MattermostPostSchema.safeParse(await monitor.client.request(`/posts/${encodeURIComponent(nativeThreadRootId)}`));
|
|
2437
|
+
isBotOwnedThread = root.success && root.data.id === nativeThreadRootId && root.data.channel_id === channelId && root.data.user_id === botUserId && !root.data.delete_at && !normalizeOptionalString(root.data.root_id);
|
|
2438
|
+
} catch (err) {
|
|
2439
|
+
monitor.logVerboseMessage(`mattermost: failed resolving thread owner channel=${channelId} root=${nativeThreadRootId}: ${String(err)}`);
|
|
2440
|
+
}
|
|
2441
|
+
const botThreadPolicy = resolveBotThreadMentionPolicy({
|
|
2442
|
+
isBotOwnedThread,
|
|
2443
|
+
requireMentionInBotThreads,
|
|
2444
|
+
requireMention: shouldRequireMention || oncharEnabled,
|
|
2445
|
+
implicitMentionKinds: implicitMentionKindWhen("bot_thread_participant", threadAlreadyEngaged)
|
|
2446
|
+
});
|
|
2447
|
+
const botThreadMentionRequired = isBotOwnedThread && requireMentionInBotThreads === true;
|
|
2676
2448
|
const mentionDecision = resolveMattermostInboundMentionDecision({
|
|
2677
2449
|
cfg,
|
|
2678
2450
|
accountId: account.accountId,
|
|
2679
2451
|
kind,
|
|
2680
|
-
requireMention:
|
|
2681
|
-
canDetectMention: canDetectMention || oncharEnabled,
|
|
2452
|
+
requireMention: botThreadPolicy.requireMention,
|
|
2453
|
+
canDetectMention: canDetectMention || oncharEnabled || botThreadMentionRequired,
|
|
2682
2454
|
wasMentioned: wasMentioned || oncharTriggered,
|
|
2683
|
-
implicitMentionKinds:
|
|
2455
|
+
implicitMentionKinds: botThreadPolicy.implicitMentionKinds,
|
|
2684
2456
|
allowTextCommands,
|
|
2685
2457
|
hasControlCommand: isControlCommand,
|
|
2686
2458
|
commandAuthorized
|
|
@@ -2698,7 +2470,7 @@ function createMattermostPostHandler(monitor) {
|
|
|
2698
2470
|
reason: "no mention",
|
|
2699
2471
|
target: channelId,
|
|
2700
2472
|
onceKey: JSON.stringify([account.accountId, channelId]),
|
|
2701
|
-
hint: `Mention patterns can be derived from the agent identity name. Set ${groupsConfigPath}[${JSON.stringify(channelId)}]
|
|
2473
|
+
hint: `Mention patterns can be derived from the agent identity name. Set ${groupsConfigPath}[${JSON.stringify(channelId)}].${botThreadMentionRequired ? "requireMentionInBotThreads" : "requireMention"}=false to process messages without a mention. Preserve existing groups entries; when adding the first groups map, include "*": {} to keep other chats admitted.`
|
|
2702
2474
|
});
|
|
2703
2475
|
recordPendingHistory();
|
|
2704
2476
|
return;
|
|
@@ -2723,7 +2495,7 @@ function createMattermostPostHandler(monitor) {
|
|
|
2723
2495
|
accountId: account.accountId,
|
|
2724
2496
|
direction: "inbound"
|
|
2725
2497
|
});
|
|
2726
|
-
const fromLabel = formatInboundFromLabel
|
|
2498
|
+
const fromLabel = formatInboundFromLabel({
|
|
2727
2499
|
isGroup: kind !== "direct",
|
|
2728
2500
|
groupLabel: channelDisplay || roomLabel,
|
|
2729
2501
|
groupId: channelId,
|
|
@@ -2844,13 +2616,18 @@ function createMattermostReactionHandler(monitor) {
|
|
|
2844
2616
|
monitor.logVerboseMessage("mattermost: drop reaction (no channel_id in broadcast, cannot enforce policy)");
|
|
2845
2617
|
return;
|
|
2846
2618
|
}
|
|
2619
|
+
const reactedPost = await monitor.resources.resolvePostInfo(postId);
|
|
2847
2620
|
const eventPlan = await buildMattermostEventPlan(monitor, {
|
|
2848
2621
|
channelId,
|
|
2849
2622
|
senderId: userId,
|
|
2623
|
+
...reactedPost ? {
|
|
2624
|
+
postId: reactedPost.id,
|
|
2625
|
+
threadRootId: normalizeOptionalString(reactedPost.root_id)
|
|
2626
|
+
} : {},
|
|
2850
2627
|
dropLabel: "reaction"
|
|
2851
2628
|
});
|
|
2852
2629
|
if (!eventPlan) return;
|
|
2853
|
-
const { kind,
|
|
2630
|
+
const { kind, thread } = eventPlan;
|
|
2854
2631
|
const reactionAccess = await resolveMattermostMonitorInboundAccess({
|
|
2855
2632
|
account,
|
|
2856
2633
|
cfg,
|
|
@@ -2871,7 +2648,7 @@ function createMattermostReactionHandler(monitor) {
|
|
|
2871
2648
|
}
|
|
2872
2649
|
const eventText = `Mattermost reaction ${action}: :${emojiName}: by @${senderName} on post ${postId} in channel ${channelId}`;
|
|
2873
2650
|
core.system.enqueueSystemEvent(eventText, {
|
|
2874
|
-
sessionKey:
|
|
2651
|
+
sessionKey: thread.sessionKey,
|
|
2875
2652
|
contextKey: `mattermost:reaction:${postId}:${emojiName}:${userId}:${action}`
|
|
2876
2653
|
});
|
|
2877
2654
|
monitor.logVerboseMessage(`mattermost reaction: ${action} :${emojiName}: by ${senderName} on ${postId}`);
|
|
@@ -2922,28 +2699,6 @@ function warnOnSuspiciousCallbackUrl(params) {
|
|
|
2922
2699
|
if (isLoopbackHost(callbackHost) && !isLoopbackHost(mmHost)) params.runtime.error?.(`mattermost: slash commands callbackUrl resolved to ${params.callbackUrl} (loopback) while baseUrl is ${params.baseUrl}. This MAY be unreachable depending on your deployment. If native slash commands don't work, set channels.mattermost.commands.callbackUrl to a URL reachable from the Mattermost server (e.g. your public reverse proxy URL).`);
|
|
2923
2700
|
} catch {}
|
|
2924
2701
|
}
|
|
2925
|
-
async function registerSlashCommandsAcrossTeams(params) {
|
|
2926
|
-
const registered = [];
|
|
2927
|
-
let teamRegistrationFailures = 0;
|
|
2928
|
-
for (const team of params.teams) try {
|
|
2929
|
-
const created = await registerSlashCommands({
|
|
2930
|
-
client: params.client,
|
|
2931
|
-
teamId: team.id,
|
|
2932
|
-
creatorUserId: params.botUserId,
|
|
2933
|
-
callbackUrl: params.callbackUrl,
|
|
2934
|
-
commands: params.commands,
|
|
2935
|
-
log: (msg) => params.runtime.log?.(msg)
|
|
2936
|
-
});
|
|
2937
|
-
registered.push(...created);
|
|
2938
|
-
} catch (err) {
|
|
2939
|
-
teamRegistrationFailures += 1;
|
|
2940
|
-
params.runtime.error?.(`mattermost: failed to register slash commands for team ${team.id}: ${String(err)}`);
|
|
2941
|
-
}
|
|
2942
|
-
return {
|
|
2943
|
-
registered,
|
|
2944
|
-
teamRegistrationFailures
|
|
2945
|
-
};
|
|
2946
|
-
}
|
|
2947
2702
|
async function registerMattermostMonitorSlashCommands(params) {
|
|
2948
2703
|
const commandsRaw = params.account.config.commands;
|
|
2949
2704
|
const slashConfig = resolveSlashCommandConfig(commandsRaw);
|
|
@@ -2952,7 +2707,7 @@ async function registerMattermostMonitorSlashCommands(params) {
|
|
|
2952
2707
|
const teams = await fetchMattermostUserTeams(params.client, params.botUserId);
|
|
2953
2708
|
const slashCallbackUrl = resolveCallbackUrl({
|
|
2954
2709
|
config: slashConfig,
|
|
2955
|
-
gatewayPort: resolveGatewayPort(params.cfg),
|
|
2710
|
+
gatewayPort: (0, gateway_config_runtime_exports.resolveGatewayPort)(params.cfg),
|
|
2956
2711
|
gatewayHost: params.cfg.gateway?.customBindHost ?? void 0
|
|
2957
2712
|
});
|
|
2958
2713
|
warnOnSuspiciousCallbackUrl({
|
|
@@ -2965,14 +2720,22 @@ async function registerMattermostMonitorSlashCommands(params) {
|
|
|
2965
2720
|
runtime: params.runtime,
|
|
2966
2721
|
nativeSkills: slashConfig.nativeSkills === true
|
|
2967
2722
|
}));
|
|
2968
|
-
const
|
|
2969
|
-
|
|
2970
|
-
|
|
2971
|
-
|
|
2972
|
-
|
|
2973
|
-
|
|
2974
|
-
|
|
2975
|
-
|
|
2723
|
+
const registered = [];
|
|
2724
|
+
let teamRegistrationFailures = 0;
|
|
2725
|
+
for (const team of teams) try {
|
|
2726
|
+
const created = await registerSlashCommands({
|
|
2727
|
+
client: params.client,
|
|
2728
|
+
teamId: team.id,
|
|
2729
|
+
creatorUserId: params.botUserId,
|
|
2730
|
+
callbackUrl: slashCallbackUrl,
|
|
2731
|
+
commands: dedupedCommands,
|
|
2732
|
+
log: (msg) => params.runtime.log?.(msg)
|
|
2733
|
+
});
|
|
2734
|
+
registered.push(...created);
|
|
2735
|
+
} catch (err) {
|
|
2736
|
+
teamRegistrationFailures += 1;
|
|
2737
|
+
params.runtime.error?.(`mattermost: failed to register slash commands for team ${team.id}: ${String(err)}`);
|
|
2738
|
+
}
|
|
2976
2739
|
if (registered.length === 0) {
|
|
2977
2740
|
params.runtime.error?.("mattermost: native slash commands enabled but no commands could be registered; keeping slash callbacks inactive");
|
|
2978
2741
|
return;
|
|
@@ -3008,14 +2771,13 @@ async function runWithReconnect(connectFn, opts = {}) {
|
|
|
3008
2771
|
const { initialDelayMs = 2e3, maxDelayMs = 6e4 } = opts;
|
|
3009
2772
|
const jitterRatio = Math.max(0, opts.jitterRatio ?? 0);
|
|
3010
2773
|
const random = opts.random ?? Math.random;
|
|
3011
|
-
|
|
2774
|
+
let retryDelay = initialDelayMs;
|
|
3012
2775
|
let attempt = 0;
|
|
3013
2776
|
while (!opts.abortSignal?.aborted) {
|
|
3014
2777
|
let outcome = "resolved";
|
|
3015
2778
|
let error;
|
|
3016
2779
|
try {
|
|
3017
2780
|
await connectFn();
|
|
3018
|
-
backoff.reset();
|
|
3019
2781
|
} catch (err) {
|
|
3020
2782
|
if (opts.abortSignal?.aborted) return;
|
|
3021
2783
|
outcome = "rejected";
|
|
@@ -3023,7 +2785,8 @@ async function runWithReconnect(connectFn, opts = {}) {
|
|
|
3023
2785
|
opts.onError?.(err);
|
|
3024
2786
|
}
|
|
3025
2787
|
if (opts.abortSignal?.aborted) return;
|
|
3026
|
-
|
|
2788
|
+
if (outcome === "resolved") retryDelay = initialDelayMs;
|
|
2789
|
+
const delayMs = withJitter(retryDelay, jitterRatio, random);
|
|
3027
2790
|
if (!(opts.shouldReconnect?.({
|
|
3028
2791
|
attempt,
|
|
3029
2792
|
delayMs,
|
|
@@ -3032,22 +2795,10 @@ async function runWithReconnect(connectFn, opts = {}) {
|
|
|
3032
2795
|
}) ?? true)) return;
|
|
3033
2796
|
opts.onReconnect?.(delayMs);
|
|
3034
2797
|
await sleepAbortable(delayMs, opts.abortSignal);
|
|
3035
|
-
if (outcome === "rejected")
|
|
2798
|
+
if (outcome === "rejected") retryDelay = Math.min(retryDelay * 2, maxDelayMs);
|
|
3036
2799
|
attempt++;
|
|
3037
2800
|
}
|
|
3038
2801
|
}
|
|
3039
|
-
function createReconnectBackoff(initialDelayMs, maxDelayMs) {
|
|
3040
|
-
let retryDelay = initialDelayMs;
|
|
3041
|
-
return {
|
|
3042
|
-
current: () => retryDelay,
|
|
3043
|
-
reset: () => {
|
|
3044
|
-
retryDelay = initialDelayMs;
|
|
3045
|
-
},
|
|
3046
|
-
increase: () => {
|
|
3047
|
-
retryDelay = Math.min(retryDelay * 2, maxDelayMs);
|
|
3048
|
-
}
|
|
3049
|
-
};
|
|
3050
|
-
}
|
|
3051
2802
|
function withJitter(baseMs, jitterRatio, random) {
|
|
3052
2803
|
if (jitterRatio <= 0) return baseMs;
|
|
3053
2804
|
const normalized = Math.max(0, Math.min(1, random()));
|
|
@@ -3155,7 +2906,7 @@ async function monitorMattermostProvider(opts = {}) {
|
|
|
3155
2906
|
resolveChannelLimitMb: () => account.config.mediaMaxMb,
|
|
3156
2907
|
accountId: account.accountId
|
|
3157
2908
|
}) ?? 8388608;
|
|
3158
|
-
const { groupPolicy, providerMissingFallbackApplied } = resolveAllowlistProviderRuntimeGroupPolicy
|
|
2909
|
+
const { groupPolicy, providerMissingFallbackApplied } = resolveAllowlistProviderRuntimeGroupPolicy({
|
|
3159
2910
|
providerConfigPresent: cfg.channels?.mattermost !== void 0,
|
|
3160
2911
|
groupPolicy: account.config.groupPolicy,
|
|
3161
2912
|
defaultGroupPolicy: resolveDefaultGroupPolicy(cfg)
|
|
@@ -3319,244 +3070,4 @@ async function monitorMattermostProvider(opts = {}) {
|
|
|
3319
3070
|
if (slashShutdownCleanupPromise) await Promise.resolve(slashShutdownCleanupPromise);
|
|
3320
3071
|
}
|
|
3321
3072
|
//#endregion
|
|
3322
|
-
|
|
3323
|
-
async function probeMattermost(baseUrl, botToken, timeoutMs = 2500, allowPrivateNetwork = false, deps) {
|
|
3324
|
-
const normalized = normalizeMattermostBaseUrl(baseUrl);
|
|
3325
|
-
if (!normalized) return {
|
|
3326
|
-
ok: false,
|
|
3327
|
-
error: "baseUrl missing"
|
|
3328
|
-
};
|
|
3329
|
-
const url = `${normalized}/api/v4/users/me`;
|
|
3330
|
-
const headers = { Authorization: `Bearer ${botToken}` };
|
|
3331
|
-
return await runChannelProbe(void 0, async ({ elapsedMs }) => {
|
|
3332
|
-
const resolvedTimeoutMs = timeoutMs > 0 ? resolveTimerTimeoutMs(timeoutMs, 2500) : void 0;
|
|
3333
|
-
const { response: res, release } = await fetchWithSsrFGuard({
|
|
3334
|
-
url,
|
|
3335
|
-
init: { headers },
|
|
3336
|
-
auditContext: "mattermost-probe",
|
|
3337
|
-
policy: ssrfPolicyFromPrivateNetworkOptIn(allowPrivateNetwork),
|
|
3338
|
-
...resolvedTimeoutMs !== void 0 ? { timeoutMs: resolvedTimeoutMs } : {},
|
|
3339
|
-
...deps?.fetchImpl ? { fetchImpl: deps.fetchImpl } : {},
|
|
3340
|
-
...deps?.lookupFn ? { lookupFn: deps.lookupFn } : {}
|
|
3341
|
-
});
|
|
3342
|
-
const requestElapsedMs = elapsedMs();
|
|
3343
|
-
try {
|
|
3344
|
-
if (!res.ok) {
|
|
3345
|
-
const detail = await readMattermostError(res, headers);
|
|
3346
|
-
return {
|
|
3347
|
-
ok: false,
|
|
3348
|
-
status: res.status,
|
|
3349
|
-
error: detail || res.statusText,
|
|
3350
|
-
elapsedMs: requestElapsedMs
|
|
3351
|
-
};
|
|
3352
|
-
}
|
|
3353
|
-
const bot = await readProviderJsonResponse(res, "Mattermost probe /users/me");
|
|
3354
|
-
return {
|
|
3355
|
-
ok: true,
|
|
3356
|
-
status: res.status,
|
|
3357
|
-
elapsedMs: requestElapsedMs,
|
|
3358
|
-
bot
|
|
3359
|
-
};
|
|
3360
|
-
} finally {
|
|
3361
|
-
await release();
|
|
3362
|
-
}
|
|
3363
|
-
}, (error) => ({
|
|
3364
|
-
ok: false,
|
|
3365
|
-
status: null,
|
|
3366
|
-
error: formatErrorMessage(error)
|
|
3367
|
-
}));
|
|
3368
|
-
}
|
|
3369
|
-
//#endregion
|
|
3370
|
-
//#region extensions/mattermost/src/mattermost/reactions.ts
|
|
3371
|
-
const BOT_USER_CACHE_TTL_MS = 6e5;
|
|
3372
|
-
const botUserIdCache = /* @__PURE__ */ new Map();
|
|
3373
|
-
async function resolveBotUserId(client, cacheKey) {
|
|
3374
|
-
const rawNow = Date.now();
|
|
3375
|
-
const now = asDateTimestampMs(rawNow);
|
|
3376
|
-
const cached = botUserIdCache.get(cacheKey);
|
|
3377
|
-
if (cached) {
|
|
3378
|
-
if (now !== void 0 && cached.expiresAt > now) return cached.userId;
|
|
3379
|
-
botUserIdCache.delete(cacheKey);
|
|
3380
|
-
}
|
|
3381
|
-
const userId = (await fetchMattermostMe(client))?.id?.trim();
|
|
3382
|
-
if (!userId) return null;
|
|
3383
|
-
const expiresAt = resolveExpiresAtMsFromDurationMs(BOT_USER_CACHE_TTL_MS, { nowMs: rawNow });
|
|
3384
|
-
if (expiresAt !== void 0) botUserIdCache.set(cacheKey, {
|
|
3385
|
-
userId,
|
|
3386
|
-
expiresAt
|
|
3387
|
-
});
|
|
3388
|
-
return userId;
|
|
3389
|
-
}
|
|
3390
|
-
async function addMattermostReaction(params) {
|
|
3391
|
-
return runMattermostReaction(params, {
|
|
3392
|
-
action: "add",
|
|
3393
|
-
mutation: createReaction
|
|
3394
|
-
});
|
|
3395
|
-
}
|
|
3396
|
-
async function removeMattermostReaction(params) {
|
|
3397
|
-
return runMattermostReaction(params, {
|
|
3398
|
-
action: "remove",
|
|
3399
|
-
mutation: deleteReaction
|
|
3400
|
-
});
|
|
3401
|
-
}
|
|
3402
|
-
function parseAuthorizedReactionTarget(rawTarget) {
|
|
3403
|
-
const normalized = rawTarget ? normalizeMattermostMessagingTarget(rawTarget) : void 0;
|
|
3404
|
-
if (!normalized) return null;
|
|
3405
|
-
if (normalized.startsWith("channel:")) {
|
|
3406
|
-
const id = normalized.slice(8).trim();
|
|
3407
|
-
return id ? {
|
|
3408
|
-
kind: "channel",
|
|
3409
|
-
id
|
|
3410
|
-
} : null;
|
|
3411
|
-
}
|
|
3412
|
-
if (normalized.startsWith("user:")) {
|
|
3413
|
-
const id = normalized.slice(5).trim();
|
|
3414
|
-
return id ? {
|
|
3415
|
-
kind: "user",
|
|
3416
|
-
id
|
|
3417
|
-
} : null;
|
|
3418
|
-
}
|
|
3419
|
-
return null;
|
|
3420
|
-
}
|
|
3421
|
-
async function authorizeMattermostReactionResource(params) {
|
|
3422
|
-
const target = parseAuthorizedReactionTarget(params.authorizedTarget);
|
|
3423
|
-
if (!target) throw new Error("Mattermost delegated reactions require a canonical authorized conversation target.");
|
|
3424
|
-
const postChannelId = (await params.client.request(`/posts/${encodeURIComponent(params.postId)}`)).channel_id?.trim();
|
|
3425
|
-
if (!postChannelId) throw new Error("Mattermost reaction post is missing its conversation binding.");
|
|
3426
|
-
if (target.kind === "channel") {
|
|
3427
|
-
if (postChannelId !== target.id) throw new Error("Mattermost reaction post belongs to a different conversation.");
|
|
3428
|
-
return;
|
|
3429
|
-
}
|
|
3430
|
-
const botUserId = await resolveBotUserId(params.client, params.cacheKey);
|
|
3431
|
-
if (!botUserId) throw new Error("Mattermost reactions failed: could not resolve bot user id.");
|
|
3432
|
-
const channel = await fetchMattermostChannel(params.client, postChannelId);
|
|
3433
|
-
const participants = channel.name?.split("__").map((entry) => entry.trim()).filter(Boolean).toSorted() ?? [];
|
|
3434
|
-
const authorizedParticipants = [botUserId, target.id].toSorted();
|
|
3435
|
-
if (channel.type !== "D" || participants.length !== 2 || participants[0] !== authorizedParticipants[0] || participants[1] !== authorizedParticipants[1]) throw new Error("Mattermost reaction post belongs to a different direct conversation.");
|
|
3436
|
-
return botUserId;
|
|
3437
|
-
}
|
|
3438
|
-
async function runMattermostReaction(params, options) {
|
|
3439
|
-
const resolved = resolveMattermostAccount({
|
|
3440
|
-
cfg: params.cfg,
|
|
3441
|
-
accountId: params.accountId
|
|
3442
|
-
});
|
|
3443
|
-
const baseUrl = resolved.baseUrl?.trim();
|
|
3444
|
-
const botToken = resolved.botToken?.trim();
|
|
3445
|
-
if (!baseUrl || !botToken) return {
|
|
3446
|
-
ok: false,
|
|
3447
|
-
error: "Mattermost botToken/baseUrl missing."
|
|
3448
|
-
};
|
|
3449
|
-
const client = createMattermostClient({
|
|
3450
|
-
baseUrl,
|
|
3451
|
-
botToken,
|
|
3452
|
-
fetchImpl: params.fetchImpl,
|
|
3453
|
-
allowPrivateNetwork: isPrivateNetworkOptInEnabled(resolved.config)
|
|
3454
|
-
});
|
|
3455
|
-
const cacheKey = `${baseUrl}:${botToken}`;
|
|
3456
|
-
try {
|
|
3457
|
-
const userId = (params.conversationReadOrigin === "direct-operator" ? void 0 : await authorizeMattermostReactionResource({
|
|
3458
|
-
client,
|
|
3459
|
-
cacheKey,
|
|
3460
|
-
postId: params.postId,
|
|
3461
|
-
authorizedTarget: params.authorizedTarget
|
|
3462
|
-
})) ?? await resolveBotUserId(client, cacheKey);
|
|
3463
|
-
if (!userId) return {
|
|
3464
|
-
ok: false,
|
|
3465
|
-
error: "Mattermost reactions failed: could not resolve bot user id."
|
|
3466
|
-
};
|
|
3467
|
-
await options.mutation(client, {
|
|
3468
|
-
userId,
|
|
3469
|
-
postId: params.postId,
|
|
3470
|
-
emojiName: params.emojiName
|
|
3471
|
-
});
|
|
3472
|
-
} catch (err) {
|
|
3473
|
-
return {
|
|
3474
|
-
ok: false,
|
|
3475
|
-
error: `Mattermost ${options.action} reaction failed: ${String(err)}`
|
|
3476
|
-
};
|
|
3477
|
-
}
|
|
3478
|
-
return { ok: true };
|
|
3479
|
-
}
|
|
3480
|
-
async function createReaction(client, params) {
|
|
3481
|
-
await client.request("/reactions", {
|
|
3482
|
-
method: "POST",
|
|
3483
|
-
body: JSON.stringify({
|
|
3484
|
-
user_id: params.userId,
|
|
3485
|
-
post_id: params.postId,
|
|
3486
|
-
emoji_name: params.emojiName
|
|
3487
|
-
})
|
|
3488
|
-
});
|
|
3489
|
-
}
|
|
3490
|
-
async function deleteReaction(client, params) {
|
|
3491
|
-
const emoji = encodeURIComponent(params.emojiName);
|
|
3492
|
-
await client.request(`/users/${params.userId}/posts/${params.postId}/reactions/${emoji}`, { method: "DELETE" });
|
|
3493
|
-
}
|
|
3494
|
-
//#endregion
|
|
3495
|
-
//#region extensions/mattermost/src/mattermost/read.ts
|
|
3496
|
-
function parseMattermostChannelTarget(rawTarget) {
|
|
3497
|
-
const normalized = normalizeMattermostMessagingTarget(rawTarget);
|
|
3498
|
-
if (normalized?.startsWith("channel:")) return normalized.slice(8).trim() || void 0;
|
|
3499
|
-
const trimmed = rawTarget.trim();
|
|
3500
|
-
return trimmed && !trimmed.includes(":") ? trimmed : void 0;
|
|
3501
|
-
}
|
|
3502
|
-
function isCurrentMattermostReadTarget(params) {
|
|
3503
|
-
const toolContext = params.context.toolContext;
|
|
3504
|
-
const requesterAccountId = params.context.requesterAccountId?.trim();
|
|
3505
|
-
if (normalizeLowercaseStringOrEmpty(toolContext?.currentChannelProvider) !== "mattermost" || !requesterAccountId || normalizeAccountId(requesterAccountId) !== normalizeAccountId(params.accountId)) return false;
|
|
3506
|
-
const nativeChannelId = toolContext?.currentChannelId;
|
|
3507
|
-
if (typeof nativeChannelId === "string" && nativeChannelId.trim()) return parseMattermostChannelTarget(nativeChannelId) === params.channelId;
|
|
3508
|
-
const messagingTarget = toolContext?.currentMessagingTarget;
|
|
3509
|
-
return typeof messagingTarget === "string" && Boolean(messagingTarget.trim()) && parseMattermostChannelTarget(messagingTarget) === params.channelId;
|
|
3510
|
-
}
|
|
3511
|
-
function isConfiguredMattermostReadTarget(params) {
|
|
3512
|
-
const { groupPolicy } = resolveAllowlistProviderRuntimeGroupPolicy({
|
|
3513
|
-
providerConfigPresent: params.cfg.channels?.mattermost !== void 0,
|
|
3514
|
-
groupPolicy: params.account.config.groupPolicy,
|
|
3515
|
-
defaultGroupPolicy: params.cfg.channels?.defaults?.groupPolicy
|
|
3516
|
-
});
|
|
3517
|
-
if (groupPolicy === "disabled") return false;
|
|
3518
|
-
if (groupPolicy === "open") return true;
|
|
3519
|
-
const groups = params.account.config.groups;
|
|
3520
|
-
return groups?.[params.channelId] !== void 0 || groups?.["*"] !== void 0;
|
|
3521
|
-
}
|
|
3522
|
-
async function readMattermostMessages(params) {
|
|
3523
|
-
const account = resolveMattermostAccount({
|
|
3524
|
-
cfg: params.cfg,
|
|
3525
|
-
accountId: params.accountId
|
|
3526
|
-
});
|
|
3527
|
-
if (!account.enabled) throw new Error(`Mattermost account "${account.accountId}" is disabled`);
|
|
3528
|
-
const baseUrl = account.baseUrl?.trim();
|
|
3529
|
-
const botToken = account.botToken?.trim();
|
|
3530
|
-
if (!baseUrl || !botToken) throw new Error("Mattermost botToken/baseUrl missing.");
|
|
3531
|
-
const client = createMattermostClient({
|
|
3532
|
-
baseUrl,
|
|
3533
|
-
botToken,
|
|
3534
|
-
fetchImpl: params.fetchImpl,
|
|
3535
|
-
allowPrivateNetwork: isPrivateNetworkOptInEnabled(account.config)
|
|
3536
|
-
});
|
|
3537
|
-
const directOperator = params.context.conversationReadOrigin === "direct-operator";
|
|
3538
|
-
const currentConversation = isCurrentMattermostReadTarget({
|
|
3539
|
-
accountId: account.accountId,
|
|
3540
|
-
channelId: params.channelId,
|
|
3541
|
-
context: params.context
|
|
3542
|
-
});
|
|
3543
|
-
if (!directOperator && !currentConversation) {
|
|
3544
|
-
const requesterAccountId = params.context.requesterAccountId?.trim();
|
|
3545
|
-
const sameProvider = normalizeLowercaseStringOrEmpty(params.context.toolContext?.currentChannelProvider) === "mattermost";
|
|
3546
|
-
const sameAccount = requesterAccountId && normalizeAccountId(requesterAccountId) === normalizeAccountId(account.accountId);
|
|
3547
|
-
if (!sameProvider || !sameAccount) throw new Error("Mattermost delegated reads require the current Mattermost account.");
|
|
3548
|
-
const channel = await fetchMattermostChannel(client, params.channelId);
|
|
3549
|
-
if (channel.type !== "O" && channel.type !== "P" || !isConfiguredMattermostReadTarget({
|
|
3550
|
-
cfg: params.cfg,
|
|
3551
|
-
account,
|
|
3552
|
-
channelId: params.channelId
|
|
3553
|
-
})) throw new Error("Mattermost read target channel is not allowed.");
|
|
3554
|
-
}
|
|
3555
|
-
return await fetchMattermostChannelPosts(client, params.channelId, {
|
|
3556
|
-
limit: params.limit,
|
|
3557
|
-
before: params.before,
|
|
3558
|
-
after: params.after
|
|
3559
|
-
});
|
|
3560
|
-
}
|
|
3561
|
-
//#endregion
|
|
3562
|
-
export { addMattermostReaction, listMattermostDirectoryGroups, listMattermostDirectoryPeers, monitorMattermostProvider, probeMattermost, readMattermostMessages, removeMattermostReaction, resolveMattermostOpaqueTarget, sendMessageMattermost };
|
|
3073
|
+
export { monitorMattermostProvider };
|