@openclaw/clickclack 2026.9.5 → 2026.9.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/.setup/{channel-yIQ_PUDD.mjs → channel-CT4CVd4d.mjs} +165 -91
- package/dist/.setup/{runtime-api-D9Bwyc44.mjs → runtime-api-A9r1b12d.mjs} +225 -161
- package/dist/api.js +1 -1
- package/dist/channel-plugin-api.js +1 -1
- package/dist/index.js +1 -1
- package/dist/runtime-api.js +2 -2
- 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/package.json +5 -5
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { b as resolveClickClackAccount, d as isClickClackChannelNameConflict, l as ClickClackHttpError, u as createClickClackClient, v as listClickClackAccountIds } from "./setup-surface-BBl3rvVx.mjs";
|
|
2
|
-
import { C as slugifyDiscussionLabel, D as listPendingDiscussionOpens, E as clearPendingDiscussionOpen, O as recordPendingDiscussionOpen, S as resolveDiscussionLabel, T as clearDiscussionBindingGeneration, _ as getClickClackDiscussionBindingStore, b as fallbackDiscussionLabel, c as markClickClackDiscussionChannelIdentityRevoked, d as discussionInfoForBinding, f as normalizedServerBaseUrl, g as bindingMatchesActiveSessionIncarnation, h as attachBindingToCurrentActiveSession, k as reserveDiscussionBindingGeneration, l as markClickClackDiscussionChannelRevoked, o as clearClickClackDiscussionChannelRevoked, p as resolveDiscussionBindingAccount, s as isClickClackDiscussionChannelRevoked, u as discussionAccounts, v as discussionCredentialFingerprint, w as truncateDiscussionDisplayTitle, x as isDiscussionSessionKey, y as discussionExternalRef } from "./channel-
|
|
2
|
+
import { C as slugifyDiscussionLabel, D as listPendingDiscussionOpens, E as clearPendingDiscussionOpen, O as recordPendingDiscussionOpen, S as resolveDiscussionLabel, T as clearDiscussionBindingGeneration, _ as getClickClackDiscussionBindingStore, b as fallbackDiscussionLabel, c as markClickClackDiscussionChannelIdentityRevoked, d as discussionInfoForBinding, f as normalizedServerBaseUrl, g as bindingMatchesActiveSessionIncarnation, h as attachBindingToCurrentActiveSession, k as reserveDiscussionBindingGeneration, l as markClickClackDiscussionChannelRevoked, o as clearClickClackDiscussionChannelRevoked, p as resolveDiscussionBindingAccount, s as isClickClackDiscussionChannelRevoked, u as discussionAccounts, v as discussionCredentialFingerprint, w as truncateDiscussionDisplayTitle, x as isDiscussionSessionKey, y as discussionExternalRef } from "./channel-CT4CVd4d.mjs";
|
|
3
3
|
import "../api.js";
|
|
4
4
|
import { randomUUID } from "node:crypto";
|
|
5
5
|
import { buildControlUiSessionPath, registerSessionDiscussionProvider } from "openclaw/plugin-sdk/session-discussion";
|
|
@@ -253,10 +253,10 @@ async function openClickClackDiscussionBinding(params) {
|
|
|
253
253
|
if (!workspace.route_id) throw new Error("ClickClack discussions workspace is missing its route id");
|
|
254
254
|
const serverBaseUrl = normalizedServerBaseUrl(account);
|
|
255
255
|
const credentialFingerprint = discussionCredentialFingerprint(account.token);
|
|
256
|
-
const unresolved = listPendingDiscussionOpens(runtime).find((pending) => pending.sessionKey === sessionKey);
|
|
256
|
+
const unresolved = (await listPendingDiscussionOpens(runtime)).find((pending) => pending.sessionKey === sessionKey);
|
|
257
257
|
if (unresolved && (unresolved.accountId !== account.accountId || unresolved.credentialFingerprint !== credentialFingerprint || unresolved.serverBaseUrl !== serverBaseUrl || unresolved.workspaceId !== workspace.id)) {
|
|
258
258
|
await params.reconcilePendingOpen(unresolved);
|
|
259
|
-
if (listPendingDiscussionOpens(runtime).some((pending) => pending.sessionKey === sessionKey)) throw new Error("A previous ClickClack discussion open is still unresolved; restore its credential and retry");
|
|
259
|
+
if ((await listPendingDiscussionOpens(runtime)).some((pending) => pending.sessionKey === sessionKey)) throw new Error("A previous ClickClack discussion open is still unresolved; restore its credential and retry");
|
|
260
260
|
}
|
|
261
261
|
const config = runtime.config.current();
|
|
262
262
|
const agentId = resolveSessionAgentIdStrict({
|
|
@@ -268,12 +268,21 @@ async function openClickClackDiscussionBinding(params) {
|
|
|
268
268
|
const displayTitle = label === fallback ? "" : truncateDiscussionDisplayTitle(label);
|
|
269
269
|
const section = entry.category?.trim() || account.discussions.section;
|
|
270
270
|
const externalUrl = controlSessionUrl(account.discussions.controlUrlBase, sessionKey, account.agentId ?? agentId, config.session?.mainKey, label);
|
|
271
|
+
const assertCurrentAuthority = () => {
|
|
272
|
+
const currentAccounts = discussionAccounts(runtime.config.current());
|
|
273
|
+
const currentAccount = currentAccounts.length === 1 ? currentAccounts[0] : void 0;
|
|
274
|
+
const currentEntry = runtime.agent.session.getSessionEntry({
|
|
275
|
+
sessionKey,
|
|
276
|
+
readConsistency: "latest"
|
|
277
|
+
});
|
|
278
|
+
if (!currentAccount || currentAccount.accountId !== account.accountId || normalizedServerBaseUrl(currentAccount) !== serverBaseUrl || currentAccount.apiEndpoint !== account.apiEndpoint || discussionCredentialFingerprint(currentAccount.token) !== credentialFingerprint || currentAccount.discussions.workspace !== account.discussions.workspace || !currentEntry?.sessionId || currentEntry.archivedAt !== void 0) throw new Error("ClickClack discussion authority changed while opening the channel");
|
|
279
|
+
};
|
|
271
280
|
return await params.withChannelMutationLock(async () => {
|
|
272
281
|
params.ensureBindingCapacity(sessionKey);
|
|
273
282
|
let channels = await client.channels(workspace.id);
|
|
274
283
|
assertManagedChannelListContract(channels);
|
|
275
284
|
const destinationIdentity = [serverBaseUrl, workspace.id].join("\0");
|
|
276
|
-
const bindingGeneration = reserveDiscussionBindingGeneration({
|
|
285
|
+
const bindingGeneration = await reserveDiscussionBindingGeneration({
|
|
277
286
|
runtime,
|
|
278
287
|
sessionKey,
|
|
279
288
|
accountId: account.accountId,
|
|
@@ -303,7 +312,7 @@ async function openClickClackDiscussionBinding(params) {
|
|
|
303
312
|
sidebar_section: section,
|
|
304
313
|
display_title: displayTitle
|
|
305
314
|
};
|
|
306
|
-
recordPendingDiscussionOpen({
|
|
315
|
+
await recordPendingDiscussionOpen({
|
|
307
316
|
runtime,
|
|
308
317
|
sessionKey,
|
|
309
318
|
generation: bindingGeneration,
|
|
@@ -316,7 +325,8 @@ async function openClickClackDiscussionBinding(params) {
|
|
|
316
325
|
credentialFingerprint
|
|
317
326
|
}
|
|
318
327
|
});
|
|
319
|
-
params.ensureTimer();
|
|
328
|
+
await params.ensureTimer();
|
|
329
|
+
assertCurrentAuthority();
|
|
320
330
|
try {
|
|
321
331
|
if (adopted) {
|
|
322
332
|
markClickClackDiscussionChannelIdentityRevoked({
|
|
@@ -358,16 +368,17 @@ async function openClickClackDiscussionBinding(params) {
|
|
|
358
368
|
serverBaseUrl,
|
|
359
369
|
channelId: recovered.id
|
|
360
370
|
});
|
|
371
|
+
assertCurrentAuthority();
|
|
361
372
|
resolved = await client.updateChannel(recovered.id, managedFields);
|
|
362
373
|
break;
|
|
363
374
|
}
|
|
364
|
-
if (definitiveNoCreate) clearDiscussionBindingGeneration({
|
|
375
|
+
if (definitiveNoCreate) await clearDiscussionBindingGeneration({
|
|
365
376
|
runtime,
|
|
366
377
|
sessionKey,
|
|
367
378
|
expectedGeneration: bindingGeneration
|
|
368
379
|
});
|
|
369
380
|
} catch {
|
|
370
|
-
if (definitiveNoCreate && !adopted) clearDiscussionBindingGeneration({
|
|
381
|
+
if (definitiveNoCreate && !adopted) await clearDiscussionBindingGeneration({
|
|
371
382
|
runtime,
|
|
372
383
|
sessionKey,
|
|
373
384
|
expectedGeneration: bindingGeneration
|
|
@@ -387,7 +398,7 @@ async function openClickClackDiscussionBinding(params) {
|
|
|
387
398
|
});
|
|
388
399
|
if (adopted) assertChannelPatch(resolved, managedFields);
|
|
389
400
|
} catch (error) {
|
|
390
|
-
clearPendingDiscussionOpen({
|
|
401
|
+
await clearPendingDiscussionOpen({
|
|
391
402
|
runtime,
|
|
392
403
|
sessionKey,
|
|
393
404
|
expectedGeneration: bindingGeneration
|
|
@@ -396,7 +407,7 @@ async function openClickClackDiscussionBinding(params) {
|
|
|
396
407
|
throw error;
|
|
397
408
|
}
|
|
398
409
|
if (!resolved.route_id) {
|
|
399
|
-
clearPendingDiscussionOpen({
|
|
410
|
+
await clearPendingDiscussionOpen({
|
|
400
411
|
runtime,
|
|
401
412
|
sessionKey,
|
|
402
413
|
expectedGeneration: bindingGeneration
|
|
@@ -410,7 +421,7 @@ async function openClickClackDiscussionBinding(params) {
|
|
|
410
421
|
readConsistency: "latest"
|
|
411
422
|
});
|
|
412
423
|
if (!currentEntry?.sessionId || currentEntry.archivedAt !== void 0) {
|
|
413
|
-
clearPendingDiscussionOpen({
|
|
424
|
+
await clearPendingDiscussionOpen({
|
|
414
425
|
runtime,
|
|
415
426
|
sessionKey,
|
|
416
427
|
expectedGeneration: bindingGeneration
|
|
@@ -440,6 +451,7 @@ async function openClickClackDiscussionBinding(params) {
|
|
|
440
451
|
display_title: currentDisplayTitle
|
|
441
452
|
};
|
|
442
453
|
try {
|
|
454
|
+
assertCurrentAuthority();
|
|
443
455
|
currentChannel = await client.updateChannel(channel.id, latestManagedFields);
|
|
444
456
|
assertChannelPatch(currentChannel, latestManagedFields);
|
|
445
457
|
break;
|
|
@@ -448,7 +460,7 @@ async function openClickClackDiscussionBinding(params) {
|
|
|
448
460
|
}
|
|
449
461
|
}
|
|
450
462
|
} catch (error) {
|
|
451
|
-
clearPendingDiscussionOpen({
|
|
463
|
+
await clearPendingDiscussionOpen({
|
|
452
464
|
runtime,
|
|
453
465
|
sessionKey,
|
|
454
466
|
expectedGeneration: bindingGeneration
|
|
@@ -475,9 +487,10 @@ async function openClickClackDiscussionBinding(params) {
|
|
|
475
487
|
...currentChannel.display_title !== void 0 ? { displayTitle: currentChannel.display_title } : {}
|
|
476
488
|
};
|
|
477
489
|
try {
|
|
490
|
+
assertCurrentAuthority();
|
|
478
491
|
store.set(sessionKey, nextBinding);
|
|
479
492
|
} catch (error) {
|
|
480
|
-
clearPendingDiscussionOpen({
|
|
493
|
+
await clearPendingDiscussionOpen({
|
|
481
494
|
runtime,
|
|
482
495
|
sessionKey,
|
|
483
496
|
expectedGeneration: bindingGeneration
|
|
@@ -485,10 +498,59 @@ async function openClickClackDiscussionBinding(params) {
|
|
|
485
498
|
params.warn(`unbound discussion channel remains quarantined: ${channel.id}`);
|
|
486
499
|
throw error;
|
|
487
500
|
}
|
|
488
|
-
params.finalizePendingBinding(sessionKey, nextBinding);
|
|
501
|
+
await params.finalizePendingBinding(sessionKey, nextBinding);
|
|
489
502
|
return nextBinding;
|
|
490
503
|
});
|
|
491
504
|
}
|
|
505
|
+
async function reconcilePendingDiscussionOpen(params) {
|
|
506
|
+
const { pending } = params;
|
|
507
|
+
const currentBinding = params.store.get(pending.sessionKey);
|
|
508
|
+
if (currentBinding?.externalRef === pending.externalRef) {
|
|
509
|
+
await params.finalizePendingBinding(pending.sessionKey, currentBinding);
|
|
510
|
+
return;
|
|
511
|
+
}
|
|
512
|
+
const cfg = params.runtime.config.current();
|
|
513
|
+
const account = listClickClackAccountIds(cfg).map((accountId) => resolveClickClackAccount({
|
|
514
|
+
cfg,
|
|
515
|
+
accountId
|
|
516
|
+
})).find((candidate) => candidate.configured && normalizedServerBaseUrl(candidate) === pending.serverBaseUrl && discussionCredentialFingerprint(candidate.token) === pending.credentialFingerprint);
|
|
517
|
+
if (!account) return;
|
|
518
|
+
const client = params.clientFactory(account);
|
|
519
|
+
const entry = params.runtime.agent.session.getSessionEntry({
|
|
520
|
+
sessionKey: pending.sessionKey,
|
|
521
|
+
readConsistency: "latest"
|
|
522
|
+
});
|
|
523
|
+
const activeAccounts = discussionAccounts(cfg);
|
|
524
|
+
const retryAccount = activeAccounts.length === 1 ? activeAccounts[0] : void 0;
|
|
525
|
+
if (params.allowRetry !== false && entry?.sessionId && entry.archivedAt === void 0 && retryAccount && normalizedServerBaseUrl(retryAccount) === pending.serverBaseUrl && discussionCredentialFingerprint(retryAccount.token) === pending.credentialFingerprint) {
|
|
526
|
+
if ((await params.clientFactory(retryAccount).workspaces()).find((candidate) => candidate.id === retryAccount.discussions.workspace || candidate.slug === retryAccount.discussions.workspace || candidate.name === retryAccount.discussions.workspace)?.id === pending.workspaceId) {
|
|
527
|
+
await params.open(pending.sessionKey);
|
|
528
|
+
return;
|
|
529
|
+
}
|
|
530
|
+
}
|
|
531
|
+
const channels = await client.channels(pending.workspaceId);
|
|
532
|
+
assertManagedChannelListContract(channels);
|
|
533
|
+
const channel = channels.find((candidate) => candidate.external_managed === true && candidate.external_ref === pending.externalRef);
|
|
534
|
+
if (channel) {
|
|
535
|
+
markClickClackDiscussionChannelIdentityRevoked({
|
|
536
|
+
runtime: params.runtime,
|
|
537
|
+
accountId: pending.accountId,
|
|
538
|
+
serverBaseUrl: pending.serverBaseUrl,
|
|
539
|
+
channelId: channel.id
|
|
540
|
+
});
|
|
541
|
+
await clearPendingDiscussionOpen({
|
|
542
|
+
runtime: params.runtime,
|
|
543
|
+
sessionKey: pending.sessionKey,
|
|
544
|
+
expectedGeneration: pending.generation
|
|
545
|
+
});
|
|
546
|
+
return;
|
|
547
|
+
}
|
|
548
|
+
await clearDiscussionBindingGeneration({
|
|
549
|
+
runtime: params.runtime,
|
|
550
|
+
sessionKey: pending.sessionKey,
|
|
551
|
+
expectedGeneration: pending.generation
|
|
552
|
+
});
|
|
553
|
+
}
|
|
492
554
|
//#endregion
|
|
493
555
|
//#region extensions/clickclack/src/discussions/service.ts
|
|
494
556
|
const RECONCILE_INTERVAL_MS = 6e4;
|
|
@@ -503,7 +565,7 @@ var ClickClackDiscussionService = class {
|
|
|
503
565
|
#timersEnabled;
|
|
504
566
|
#sessionLocks = /* @__PURE__ */ new Map();
|
|
505
567
|
#reconcileScheduler = new DiscussionReconcileScheduler({
|
|
506
|
-
shouldSchedule: (
|
|
568
|
+
shouldSchedule: () => !this.#closed,
|
|
507
569
|
run: async (sessionKey) => await this.reconcile(sessionKey),
|
|
508
570
|
warn: (message) => this.#logger().warn(message)
|
|
509
571
|
});
|
|
@@ -512,6 +574,9 @@ var ClickClackDiscussionService = class {
|
|
|
512
574
|
#reconcileAllPromise;
|
|
513
575
|
#unsubscribeSessionsChanged;
|
|
514
576
|
#closed = false;
|
|
577
|
+
#activation = 0;
|
|
578
|
+
#cleanupPromise;
|
|
579
|
+
#operations = /* @__PURE__ */ new Set();
|
|
515
580
|
constructor(runtime, options = {}) {
|
|
516
581
|
this.#runtime = runtime;
|
|
517
582
|
this.#store = getClickClackDiscussionBindingStore(runtime);
|
|
@@ -532,24 +597,43 @@ var ClickClackDiscussionService = class {
|
|
|
532
597
|
info: async ({ sessionKey }) => await this.info(sessionKey),
|
|
533
598
|
open: async ({ sessionKey }) => await this.open(sessionKey)
|
|
534
599
|
};
|
|
535
|
-
if (options.gatewayEvents) this.bindGatewayEvents(options.gatewayEvents)
|
|
536
|
-
|
|
600
|
+
if (options.gatewayEvents) this.bindGatewayEvents(options.gatewayEvents).catch((error) => {
|
|
601
|
+
this.#logger().warn(`discussion activation failed: ${String(error)}`);
|
|
602
|
+
});
|
|
603
|
+
if (this.#timersEnabled && !options.gatewayEvents) this.#withOperation(() => this.#ensureTimer()).catch((error) => {
|
|
604
|
+
this.#logger().warn(`discussion timer initialization failed: ${String(error)}`);
|
|
605
|
+
});
|
|
537
606
|
}
|
|
538
|
-
bindGatewayEvents(gatewayEvents) {
|
|
607
|
+
async bindGatewayEvents(gatewayEvents) {
|
|
608
|
+
const activation = ++this.#activation;
|
|
609
|
+
if (this.#cleanupPromise) await this.#cleanupPromise;
|
|
610
|
+
if (activation !== this.#activation) return;
|
|
611
|
+
this.#cleanupPromise = void 0;
|
|
539
612
|
this.#unsubscribeSessionsChanged?.();
|
|
540
613
|
this.#closed = false;
|
|
541
614
|
this.#reconcileScheduler.supersede();
|
|
542
615
|
this.#unsubscribeSessionsChanged = gatewayEvents?.onSessionsChanged((event) => {
|
|
543
|
-
this.#
|
|
616
|
+
this.#withOperation(async () => {
|
|
617
|
+
if (this.#store.get(event.sessionKey) || (await listPendingDiscussionOpens(this.#runtime)).some((pending) => pending.sessionKey === event.sessionKey)) {
|
|
618
|
+
if (activation === this.#activation) this.#reconcileScheduler.schedule(event.sessionKey);
|
|
619
|
+
}
|
|
620
|
+
}).catch((error) => {
|
|
621
|
+
this.#logger().warn(`discussion event admission failed: ${String(error)}`);
|
|
622
|
+
});
|
|
623
|
+
});
|
|
624
|
+
await this.#withOperation(async () => {
|
|
625
|
+
for (const sessionKey of await this.#listReconcileSessionKeys()) {
|
|
626
|
+
if (activation !== this.#activation) return;
|
|
627
|
+
this.#reconcileScheduler.schedule(sessionKey, 0);
|
|
628
|
+
}
|
|
629
|
+
await this.#ensureTimer();
|
|
544
630
|
});
|
|
545
|
-
for (const sessionKey of this.#listReconcileSessionKeys()) this.#reconcileScheduler.schedule(sessionKey, 0);
|
|
546
|
-
if (this.#timersEnabled) this.#ensureTimer();
|
|
547
631
|
}
|
|
548
632
|
hasEnabledAccount() {
|
|
549
633
|
return discussionAccounts(this.#currentConfig()).length === 1;
|
|
550
634
|
}
|
|
551
635
|
async info(sessionKey) {
|
|
552
|
-
return await this.#withSessionLock(sessionKey, async () => {
|
|
636
|
+
return await this.#withOperation(() => this.#withSessionLock(sessionKey, async () => {
|
|
553
637
|
if (discussionAccounts(this.#currentConfig()).length !== 1) return { state: "none" };
|
|
554
638
|
const existing = this.#store.get(sessionKey);
|
|
555
639
|
if (existing) {
|
|
@@ -563,104 +647,117 @@ var ClickClackDiscussionService = class {
|
|
|
563
647
|
return { state: "available" };
|
|
564
648
|
}
|
|
565
649
|
if (resolved.state !== "active") return { state: "none" };
|
|
566
|
-
this.#finalizePendingBinding(sessionKey, existing);
|
|
650
|
+
await this.#finalizePendingBinding(sessionKey, existing);
|
|
567
651
|
await this.#reconcileBinding(sessionKey, existing, resolved.account);
|
|
568
652
|
const current = this.#store.get(sessionKey);
|
|
569
653
|
if (!current) return { state: this.hasEnabledAccount() ? "available" : "none" };
|
|
570
654
|
return discussionInfoForBinding(current, resolved.account);
|
|
571
655
|
}
|
|
572
656
|
return { state: "available" };
|
|
573
|
-
});
|
|
657
|
+
}));
|
|
574
658
|
}
|
|
575
659
|
async open(sessionKey) {
|
|
576
|
-
return await this.#withSessionLock(sessionKey,
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
let binding;
|
|
595
|
-
try {
|
|
596
|
-
binding = await openClickClackDiscussionBinding({
|
|
597
|
-
runtime: this.#runtime,
|
|
598
|
-
store: this.#store,
|
|
599
|
-
account,
|
|
600
|
-
clientFactory: this.#clientFactory,
|
|
601
|
-
installationId: this.#installationId,
|
|
602
|
-
bindingGenerationFactory: this.#bindingGenerationFactory,
|
|
603
|
-
sessionKey,
|
|
604
|
-
ensureTimer: () => this.#ensureTimer(),
|
|
605
|
-
reconcilePendingOpen: async (pending) => await this.#reconcilePendingOpen(pending, { allowRetry: false }),
|
|
606
|
-
withChannelMutationLock: async (run) => await this.#withChannelMutationLock(run),
|
|
607
|
-
ensureBindingCapacity: (key) => this.#detachedBindings.ensureCapacity(key),
|
|
608
|
-
finalizePendingBinding: (key, nextBinding) => this.#finalizePendingBinding(key, nextBinding),
|
|
609
|
-
warn: (message) => this.#logger().warn(message)
|
|
610
|
-
});
|
|
611
|
-
} finally {
|
|
612
|
-
this.#ensureTimer();
|
|
660
|
+
return await this.#withOperation(() => this.#withSessionLock(sessionKey, () => this.#open(sessionKey)));
|
|
661
|
+
}
|
|
662
|
+
async #open(sessionKey) {
|
|
663
|
+
this.#installationId ??= await getClickClackDiscussionInstallationId(this.#runtime);
|
|
664
|
+
const accounts = discussionAccounts(this.#currentConfig());
|
|
665
|
+
if (accounts.length > 1) throw new Error("ClickClack discussions require exactly one enabled discussion account");
|
|
666
|
+
const account = accounts[0];
|
|
667
|
+
if (!account) return { state: "none" };
|
|
668
|
+
const existing = this.#store.get(sessionKey);
|
|
669
|
+
if (existing) {
|
|
670
|
+
const resolved = await this.#resolveBindingForUse(existing);
|
|
671
|
+
if (resolved.state === "retargeted") this.#revokeAndDeleteBinding(sessionKey, existing);
|
|
672
|
+
else if (resolved.state === "stale") await this.#releaseStaleBinding(sessionKey, existing);
|
|
673
|
+
else if (resolved.state === "active") {
|
|
674
|
+
await this.#finalizePendingBinding(sessionKey, existing);
|
|
675
|
+
await this.#reconcileBinding(sessionKey, existing, resolved.account);
|
|
676
|
+
const current = this.#store.get(sessionKey);
|
|
677
|
+
if (current) return discussionInfoForBinding(current, resolved.account);
|
|
613
678
|
}
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
679
|
+
}
|
|
680
|
+
let binding;
|
|
681
|
+
try {
|
|
682
|
+
binding = await openClickClackDiscussionBinding({
|
|
683
|
+
runtime: this.#runtime,
|
|
684
|
+
store: this.#store,
|
|
685
|
+
account,
|
|
686
|
+
clientFactory: this.#clientFactory,
|
|
687
|
+
installationId: this.#installationId,
|
|
688
|
+
bindingGenerationFactory: this.#bindingGenerationFactory,
|
|
689
|
+
sessionKey,
|
|
690
|
+
ensureTimer: () => this.#ensureTimer(),
|
|
691
|
+
reconcilePendingOpen: async (pending) => await this.#reconcilePendingOpen(pending, { allowRetry: false }),
|
|
692
|
+
withChannelMutationLock: async (run) => await this.#withChannelMutationLock(run),
|
|
693
|
+
ensureBindingCapacity: (key) => this.#detachedBindings.ensureCapacity(key),
|
|
694
|
+
finalizePendingBinding: (key, nextBinding) => this.#finalizePendingBinding(key, nextBinding),
|
|
695
|
+
warn: (message) => this.#logger().warn(message)
|
|
696
|
+
});
|
|
697
|
+
} finally {
|
|
698
|
+
await this.#ensureTimer();
|
|
699
|
+
}
|
|
700
|
+
if (!binding) return { state: "available" };
|
|
701
|
+
return discussionInfoForBinding(binding, account);
|
|
617
702
|
}
|
|
618
703
|
async reconcile(sessionKey) {
|
|
704
|
+
return await this.#withOperation(() => this.#reconcile(sessionKey));
|
|
705
|
+
}
|
|
706
|
+
async #reconcile(sessionKey) {
|
|
619
707
|
try {
|
|
620
708
|
await this.#withSessionLock(sessionKey, async () => {
|
|
621
709
|
const binding = this.#store.get(sessionKey);
|
|
622
710
|
if (binding) await this.#reconcileBinding(sessionKey, binding);
|
|
711
|
+
const pending = (await listPendingDiscussionOpens(this.#runtime)).find((candidate) => candidate.sessionKey === sessionKey);
|
|
712
|
+
if (pending) await this.#reconcilePendingOpen(pending);
|
|
623
713
|
});
|
|
624
|
-
const pending = listPendingDiscussionOpens(this.#runtime).find((candidate) => candidate.sessionKey === sessionKey);
|
|
625
|
-
if (pending) await this.#reconcilePendingOpen(pending);
|
|
626
714
|
} finally {
|
|
627
|
-
this.#ensureTimer();
|
|
715
|
+
await this.#ensureTimer();
|
|
628
716
|
}
|
|
629
717
|
}
|
|
630
718
|
async reconcileAll() {
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
719
|
+
return await this.#withOperation(async () => {
|
|
720
|
+
if (this.#reconcileAllPromise) return await this.#reconcileAllPromise;
|
|
721
|
+
this.#reconcileAllPromise = (async () => {
|
|
722
|
+
try {
|
|
723
|
+
for (const sessionKey of await this.#listReconcileSessionKeys()) try {
|
|
724
|
+
await this.#reconcile(sessionKey);
|
|
725
|
+
} catch (error) {
|
|
726
|
+
this.#logger().warn(`discussion reconcile failed for ${sessionKey}: ${String(error)}`);
|
|
727
|
+
}
|
|
728
|
+
} finally {
|
|
729
|
+
await this.#ensureTimer();
|
|
730
|
+
}
|
|
731
|
+
})().finally(() => {
|
|
732
|
+
this.#reconcileAllPromise = void 0;
|
|
733
|
+
});
|
|
734
|
+
return await this.#reconcileAllPromise;
|
|
640
735
|
});
|
|
641
|
-
return await this.#reconcileAllPromise;
|
|
642
736
|
}
|
|
643
737
|
async readLatestMessages(sessionKey, limit) {
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
738
|
+
return await this.#withOperation(() => this.#withSessionLock(sessionKey, async () => {
|
|
739
|
+
const binding = this.#store.get(sessionKey);
|
|
740
|
+
if (!binding) return { text: "No discussion is bound to this session." };
|
|
741
|
+
const resolved = await this.#resolveBindingForUse(binding);
|
|
742
|
+
if (resolved.state === "retargeted") return { text: "No discussion is bound to this session." };
|
|
743
|
+
if (resolved.state === "stale") return { text: "No discussion is bound to this session." };
|
|
744
|
+
if (resolved.state !== "active") return { text: "No discussion is bound to this session." };
|
|
745
|
+
const attached = this.#refreshSessionAttachment(sessionKey, binding);
|
|
746
|
+
if (!attached) return { text: "No discussion is bound to this session." };
|
|
747
|
+
if (isClickClackDiscussionChannelRevoked({
|
|
748
|
+
runtime: this.#runtime,
|
|
749
|
+
serverBaseUrl: binding.serverBaseUrl,
|
|
750
|
+
channelId: binding.channelId
|
|
751
|
+
})) return { text: "No discussion is bound to this session." };
|
|
752
|
+
return {
|
|
753
|
+
binding: attached,
|
|
754
|
+
text: formatDiscussionHistory(await this.#clientFactory(resolved.account).latestChannelMessages(attached.channelId, limit)) || "The bound discussion has no messages yet."
|
|
755
|
+
};
|
|
756
|
+
}));
|
|
661
757
|
}
|
|
662
758
|
cleanup() {
|
|
663
759
|
this.#closed = true;
|
|
760
|
+
this.#activation += 1;
|
|
664
761
|
this.#unsubscribeSessionsChanged?.();
|
|
665
762
|
this.#unsubscribeSessionsChanged = void 0;
|
|
666
763
|
this.#reconcileScheduler.supersede();
|
|
@@ -669,9 +766,11 @@ var ClickClackDiscussionService = class {
|
|
|
669
766
|
clearInterval(this.#timer);
|
|
670
767
|
this.#timer = void 0;
|
|
671
768
|
}
|
|
769
|
+
this.#cleanupPromise ??= Promise.allSettled(this.#operations).then(() => void 0);
|
|
770
|
+
return this.#cleanupPromise;
|
|
672
771
|
}
|
|
673
772
|
async #reconcileBinding(sessionKey, binding, resolvedAccount) {
|
|
674
|
-
this.#finalizePendingBinding(sessionKey, binding);
|
|
773
|
+
await this.#finalizePendingBinding(sessionKey, binding);
|
|
675
774
|
if (isClickClackDiscussionChannelRevoked({
|
|
676
775
|
runtime: this.#runtime,
|
|
677
776
|
serverBaseUrl: binding.serverBaseUrl,
|
|
@@ -690,10 +789,7 @@ var ClickClackDiscussionService = class {
|
|
|
690
789
|
}
|
|
691
790
|
const activeBinding = this.#detachedBindings.clear(sessionKey, binding);
|
|
692
791
|
if (!activeBinding) return;
|
|
693
|
-
const resolved = resolvedAccount ?
|
|
694
|
-
state: "active",
|
|
695
|
-
account: resolvedAccount
|
|
696
|
-
} : await this.#resolveBindingForUse(activeBinding);
|
|
792
|
+
const resolved = resolvedAccount ? resolveDiscussionBindingAccount(this.#currentConfig(), activeBinding) : await this.#resolveBindingForUse(activeBinding);
|
|
697
793
|
if (resolved.state === "retargeted") {
|
|
698
794
|
this.#revokeAndDeleteBinding(sessionKey, activeBinding);
|
|
699
795
|
return;
|
|
@@ -774,55 +870,18 @@ var ClickClackDiscussionService = class {
|
|
|
774
870
|
}
|
|
775
871
|
}
|
|
776
872
|
async #reconcilePendingOpen(pending, options = {}) {
|
|
777
|
-
|
|
778
|
-
if (currentBinding?.externalRef === pending.externalRef) {
|
|
779
|
-
this.#finalizePendingBinding(pending.sessionKey, currentBinding);
|
|
780
|
-
return;
|
|
781
|
-
}
|
|
782
|
-
const cfg = this.#currentConfig();
|
|
783
|
-
const account = listClickClackAccountIds(cfg).map((accountId) => resolveClickClackAccount({
|
|
784
|
-
cfg,
|
|
785
|
-
accountId
|
|
786
|
-
})).find((candidate) => candidate.configured && normalizedServerBaseUrl(candidate) === pending.serverBaseUrl && discussionCredentialFingerprint(candidate.token) === pending.credentialFingerprint);
|
|
787
|
-
if (!account) return;
|
|
788
|
-
const client = this.#clientFactory(account);
|
|
789
|
-
const entry = this.#runtime.agent.session.getSessionEntry({
|
|
790
|
-
sessionKey: pending.sessionKey,
|
|
791
|
-
readConsistency: "latest"
|
|
792
|
-
});
|
|
793
|
-
const activeAccounts = discussionAccounts(cfg);
|
|
794
|
-
const retryAccount = activeAccounts.length === 1 ? activeAccounts[0] : void 0;
|
|
795
|
-
if (options.allowRetry !== false && entry?.sessionId && entry.archivedAt === void 0 && retryAccount && normalizedServerBaseUrl(retryAccount) === pending.serverBaseUrl && discussionCredentialFingerprint(retryAccount.token) === pending.credentialFingerprint) {
|
|
796
|
-
if ((await this.#clientFactory(retryAccount).workspaces()).find((candidate) => candidate.id === retryAccount.discussions.workspace || candidate.slug === retryAccount.discussions.workspace || candidate.name === retryAccount.discussions.workspace)?.id === pending.workspaceId) {
|
|
797
|
-
await this.open(pending.sessionKey);
|
|
798
|
-
return;
|
|
799
|
-
}
|
|
800
|
-
}
|
|
801
|
-
const channels = await client.channels(pending.workspaceId);
|
|
802
|
-
assertManagedChannelListContract(channels);
|
|
803
|
-
const channel = channels.find((candidate) => candidate.external_managed === true && candidate.external_ref === pending.externalRef);
|
|
804
|
-
if (channel) {
|
|
805
|
-
markClickClackDiscussionChannelIdentityRevoked({
|
|
806
|
-
runtime: this.#runtime,
|
|
807
|
-
accountId: pending.accountId,
|
|
808
|
-
serverBaseUrl: pending.serverBaseUrl,
|
|
809
|
-
channelId: channel.id
|
|
810
|
-
});
|
|
811
|
-
clearPendingDiscussionOpen({
|
|
812
|
-
runtime: this.#runtime,
|
|
813
|
-
sessionKey: pending.sessionKey,
|
|
814
|
-
expectedGeneration: pending.generation
|
|
815
|
-
});
|
|
816
|
-
return;
|
|
817
|
-
}
|
|
818
|
-
clearDiscussionBindingGeneration({
|
|
873
|
+
await reconcilePendingDiscussionOpen({
|
|
819
874
|
runtime: this.#runtime,
|
|
820
|
-
|
|
821
|
-
|
|
875
|
+
store: this.#store,
|
|
876
|
+
clientFactory: this.#clientFactory,
|
|
877
|
+
pending,
|
|
878
|
+
...options,
|
|
879
|
+
finalizePendingBinding: (key, binding) => this.#finalizePendingBinding(key, binding),
|
|
880
|
+
open: (key) => this.#open(key)
|
|
822
881
|
});
|
|
823
882
|
}
|
|
824
883
|
async #releaseStaleBinding(sessionKey, binding) {
|
|
825
|
-
clearDiscussionBindingGeneration({
|
|
884
|
+
await clearDiscussionBindingGeneration({
|
|
826
885
|
runtime: this.#runtime,
|
|
827
886
|
sessionKey
|
|
828
887
|
});
|
|
@@ -832,15 +891,15 @@ var ClickClackDiscussionService = class {
|
|
|
832
891
|
markClickClackDiscussionChannelRevoked(this.#runtime, binding);
|
|
833
892
|
this.#store.delete(sessionKey);
|
|
834
893
|
}
|
|
835
|
-
#finalizePendingBinding(sessionKey, binding) {
|
|
836
|
-
const pending = listPendingDiscussionOpens(this.#runtime).find((candidate) => candidate.sessionKey === sessionKey && candidate.externalRef === binding.externalRef);
|
|
894
|
+
async #finalizePendingBinding(sessionKey, binding) {
|
|
895
|
+
const pending = (await listPendingDiscussionOpens(this.#runtime)).find((candidate) => candidate.sessionKey === sessionKey && candidate.externalRef === binding.externalRef);
|
|
837
896
|
if (pending) {
|
|
838
897
|
clearClickClackDiscussionChannelRevoked({
|
|
839
898
|
runtime: this.#runtime,
|
|
840
899
|
serverBaseUrl: binding.serverBaseUrl,
|
|
841
900
|
channelId: binding.channelId
|
|
842
901
|
});
|
|
843
|
-
clearDiscussionBindingGeneration({
|
|
902
|
+
await clearDiscussionBindingGeneration({
|
|
844
903
|
runtime: this.#runtime,
|
|
845
904
|
sessionKey,
|
|
846
905
|
expectedGeneration: pending.generation
|
|
@@ -850,13 +909,17 @@ var ClickClackDiscussionService = class {
|
|
|
850
909
|
async #resolveBindingForUse(binding) {
|
|
851
910
|
const resolved = resolveDiscussionBindingAccount(this.#currentConfig(), binding);
|
|
852
911
|
if (resolved.state !== "active") return resolved;
|
|
853
|
-
|
|
912
|
+
const workspace = (await this.#clientFactory(resolved.account).workspaces()).find((candidate) => candidate.id === resolved.account.discussions.workspace || candidate.slug === resolved.account.discussions.workspace || candidate.name === resolved.account.discussions.workspace);
|
|
913
|
+
const current = resolveDiscussionBindingAccount(this.#currentConfig(), binding);
|
|
914
|
+
if (current.state !== "active") return current;
|
|
915
|
+
return workspace?.id === binding.workspaceId ? current : { state: "retargeted" };
|
|
854
916
|
}
|
|
855
917
|
#currentConfig() {
|
|
856
918
|
return this.#runtime.config.current();
|
|
857
919
|
}
|
|
858
|
-
#ensureTimer() {
|
|
859
|
-
|
|
920
|
+
async #ensureTimer() {
|
|
921
|
+
if (this.#closed) return;
|
|
922
|
+
const hasPendingOpens = (await listPendingDiscussionOpens(this.#runtime)).length > 0;
|
|
860
923
|
const needsBindingPoll = this.#unsubscribeSessionsChanged === void 0 && this.#store.count() > 0;
|
|
861
924
|
if (this.#closed || !hasPendingOpens && !needsBindingPoll) {
|
|
862
925
|
if (this.#timer) {
|
|
@@ -869,14 +932,12 @@ var ClickClackDiscussionService = class {
|
|
|
869
932
|
this.#timer = setInterval(() => {
|
|
870
933
|
this.reconcileAll().catch((error) => {
|
|
871
934
|
this.#logger().warn(`discussion reconcile pass failed: ${String(error)}`);
|
|
872
|
-
}).finally(() => {
|
|
873
|
-
this.#ensureTimer();
|
|
874
935
|
});
|
|
875
936
|
}, RECONCILE_INTERVAL_MS);
|
|
876
937
|
this.#timer.unref?.();
|
|
877
938
|
}
|
|
878
|
-
#listReconcileSessionKeys() {
|
|
879
|
-
return /* @__PURE__ */ new Set([...this.#store.entries().map(({ sessionKey }) => sessionKey), ...listPendingDiscussionOpens(this.#runtime).map(({ sessionKey }) => sessionKey)]);
|
|
939
|
+
async #listReconcileSessionKeys() {
|
|
940
|
+
return /* @__PURE__ */ new Set([...this.#store.entries().map(({ sessionKey }) => sessionKey), ...(await listPendingDiscussionOpens(this.#runtime)).map(({ sessionKey }) => sessionKey)]);
|
|
880
941
|
}
|
|
881
942
|
#logger() {
|
|
882
943
|
return this.#runtime.logging.getChildLogger({
|
|
@@ -884,6 +945,13 @@ var ClickClackDiscussionService = class {
|
|
|
884
945
|
feature: "discussions"
|
|
885
946
|
});
|
|
886
947
|
}
|
|
948
|
+
#withOperation(run) {
|
|
949
|
+
if (this.#closed) return Promise.reject(/* @__PURE__ */ new Error("ClickClack discussion service is stopped"));
|
|
950
|
+
const operation = Promise.resolve().then(run);
|
|
951
|
+
this.#operations.add(operation);
|
|
952
|
+
operation.then(() => this.#operations.delete(operation), () => this.#operations.delete(operation));
|
|
953
|
+
return operation;
|
|
954
|
+
}
|
|
887
955
|
async #withSessionLock(sessionKey, run) {
|
|
888
956
|
const current = (this.#sessionLocks.get(sessionKey) ?? Promise.resolve()).catch(() => void 0).then(run);
|
|
889
957
|
this.#sessionLocks.set(sessionKey, current);
|
|
@@ -981,12 +1049,8 @@ function registerClickClackDiscussions(api) {
|
|
|
981
1049
|
const service = new ClickClackDiscussionService(api.runtime);
|
|
982
1050
|
api.registerService({
|
|
983
1051
|
id: "clickclack-discussion-session-events",
|
|
984
|
-
start: ({ gatewayEvents }) =>
|
|
985
|
-
|
|
986
|
-
},
|
|
987
|
-
stop: () => {
|
|
988
|
-
service.cleanup();
|
|
989
|
-
}
|
|
1052
|
+
start: ({ gatewayEvents }) => service.bindGatewayEvents(gatewayEvents),
|
|
1053
|
+
stop: () => service.cleanup()
|
|
990
1054
|
});
|
|
991
1055
|
api.registerTool((context) => createClickClackDiscussionTool({
|
|
992
1056
|
service,
|
|
@@ -1011,7 +1075,7 @@ function registerClickClackDiscussions(api) {
|
|
|
1011
1075
|
description: "Stops the lifecycle reconciler for managed ClickClack discussions.",
|
|
1012
1076
|
cleanup: () => {
|
|
1013
1077
|
unregisterSessionAccess();
|
|
1014
|
-
service.cleanup();
|
|
1078
|
+
return service.cleanup();
|
|
1015
1079
|
}
|
|
1016
1080
|
});
|
|
1017
1081
|
}
|
package/dist/api.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import { _ as DEFAULT_ACCOUNT_ID, b as resolveClickClackAccount, p as clickClackConfigSchema, u as createClickClackClient, v as listClickClackAccountIds, x as resolveDefaultClickClackAccountId, y as listEnabledClickClackAccounts } from "./.setup/setup-surface-BBl3rvVx.mjs";
|
|
2
|
-
import { a as setClickClackRuntime, i as getClickClackRuntime, n as buildClickClackTarget, r as parseClickClackTarget, t as clickClackPlugin } from "./.setup/channel-
|
|
2
|
+
import { a as setClickClackRuntime, i as getClickClackRuntime, n as buildClickClackTarget, r as parseClickClackTarget, t as clickClackPlugin } from "./.setup/channel-CT4CVd4d.mjs";
|
|
3
3
|
export { DEFAULT_ACCOUNT_ID, buildClickClackTarget, clickClackConfigSchema, clickClackPlugin, createClickClackClient, getClickClackRuntime, listClickClackAccountIds, listEnabledClickClackAccounts, parseClickClackTarget, resolveClickClackAccount, resolveDefaultClickClackAccountId, setClickClackRuntime };
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { t as clickClackPlugin } from "./.setup/channel-
|
|
1
|
+
import { t as clickClackPlugin } from "./.setup/channel-CT4CVd4d.mjs";
|
|
2
2
|
export { clickClackPlugin };
|
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { t as registerClickClackDiscussions } from "./.setup/runtime-api-
|
|
1
|
+
import { t as registerClickClackDiscussions } from "./.setup/runtime-api-A9r1b12d.mjs";
|
|
2
2
|
import { defineBundledChannelEntry } from "openclaw/plugin-sdk/channel-entry-contract";
|
|
3
3
|
//#region extensions/clickclack/index.ts
|
|
4
4
|
/**
|