@openclaw/clickclack 2026.9.4 → 2026.9.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/assets/activity.svg +3 -0
- package/assets/icon.png +0 -0
- package/dist/{channel-ByvJKugM.js → .setup/channel-CT4CVd4d.mjs} +235 -128
- package/dist/{runtime-api-vd8TLXz1.js → .setup/runtime-api-A9r1b12d.mjs} +236 -169
- package/dist/.setup/secret-contract-api-C1QwGlzF.mjs +3 -0
- package/dist/{setup-claim-DHkUFaSu.js → .setup/setup-claim-t5SbtvZy.mjs} +2 -2
- package/dist/.setup/setup-plugin-api-B19mjQvl.mjs +2 -0
- package/dist/.setup/setup-plugin-api-BUwBPYpy.mjs +18 -0
- package/dist/{setup-surface-qNPMK71w.js → .setup/setup-surface-BBl3rvVx.mjs} +1 -1
- package/dist/api.js +2 -2
- package/dist/channel-plugin-api.js +1 -1
- package/dist/index.js +1 -1
- package/dist/runtime-api.js +3 -3
- package/dist/secret-contract-api.js +1 -1
- package/dist/setup-entry.js +3 -2
- package/dist/setup-plugin-api.js +1 -17
- package/node_modules/zod/README.md +29 -2
- package/node_modules/zod/compile.cjs +96 -0
- package/node_modules/zod/compile.d.cts +1 -0
- package/node_modules/zod/compile.d.ts +1 -0
- package/node_modules/zod/compile.js +52 -0
- package/node_modules/zod/index.cjs +21 -2
- package/node_modules/zod/index.d.cts +1 -2
- package/node_modules/zod/index.d.ts +1 -2
- package/node_modules/zod/index.js +5 -2
- package/node_modules/zod/locales/index.cjs +19 -0
- package/node_modules/zod/mini/index.cjs +19 -0
- package/node_modules/zod/package.json +20 -8
- package/node_modules/zod/src/compile.ts +56 -0
- package/node_modules/zod/src/index.ts +5 -2
- package/node_modules/zod/src/v3/ZodError.ts +22 -12
- package/node_modules/zod/src/v3/helpers/errorUtil.ts +1 -1
- package/node_modules/zod/src/v3/tests/error.test.ts +35 -0
- package/node_modules/zod/src/v3/tests/intersection.test.ts +18 -0
- package/node_modules/zod/src/v3/tests/language-server.test.ts +1 -2
- package/node_modules/zod/src/v3/tests/object.test.ts +3 -6
- package/node_modules/zod/src/v3/tests/readonly.test.ts +0 -80
- package/node_modules/zod/src/v3/tests/string.test.ts +6 -0
- package/node_modules/zod/src/v3/types.ts +5 -5
- package/node_modules/zod/src/v4/classic/checks.ts +1 -0
- package/node_modules/zod/src/v4/classic/compat.ts +26 -18
- package/node_modules/zod/src/v4/classic/deep-partial.ts +76 -0
- package/node_modules/zod/src/v4/classic/errors.ts +59 -44
- package/node_modules/zod/src/v4/classic/external.ts +14 -9
- package/node_modules/zod/src/v4/classic/from-json-schema.ts +363 -78
- package/node_modules/zod/src/v4/classic/in-out.ts +45 -0
- package/node_modules/zod/src/v4/classic/index.ts +2 -2
- package/node_modules/zod/src/v4/classic/iso.ts +2 -72
- package/node_modules/zod/src/v4/classic/parse.ts +10 -4
- package/node_modules/zod/src/v4/classic/schemas.ts +640 -375
- package/node_modules/zod/src/v4/classic/tests/apply.test.ts +27 -0
- package/node_modules/zod/src/v4/classic/tests/array.test.ts +2 -2
- package/node_modules/zod/src/v4/classic/tests/assignability.test.ts +186 -0
- package/node_modules/zod/src/v4/classic/tests/bigint.test.ts +36 -1
- package/node_modules/zod/src/v4/classic/tests/catch.test.ts +278 -0
- package/node_modules/zod/src/v4/classic/tests/codec-examples.test.ts +1 -2
- package/node_modules/zod/src/v4/classic/tests/codec.test.ts +2 -1
- package/node_modules/zod/src/v4/classic/tests/continuability.test.ts +3 -3
- package/node_modules/zod/src/v4/classic/tests/credit-card.test.ts +76 -0
- package/node_modules/zod/src/v4/classic/tests/cyclic-data.test.ts +985 -0
- package/node_modules/zod/src/v4/classic/tests/date.test.ts +30 -0
- package/node_modules/zod/src/v4/classic/tests/datetime.test.ts +32 -18
- package/node_modules/zod/src/v4/classic/tests/deep-partial.test.ts +380 -0
- package/node_modules/zod/src/v4/classic/tests/default-locale.test.ts +32 -0
- package/node_modules/zod/src/v4/classic/tests/default.test.ts +46 -0
- package/node_modules/zod/src/v4/classic/tests/detached-methods.test.ts +31 -7
- package/node_modules/zod/src/v4/classic/tests/discriminated-unions.test.ts +261 -13
- package/node_modules/zod/src/v4/classic/tests/enum.test.ts +20 -0
- package/node_modules/zod/src/v4/classic/tests/error-utils.test.ts +112 -2
- package/node_modules/zod/src/v4/classic/tests/error.test.ts +403 -6
- package/node_modules/zod/src/v4/classic/tests/from-json-schema.test.ts +582 -10
- package/node_modules/zod/src/v4/classic/tests/function.test.ts +31 -0
- package/node_modules/zod/src/v4/classic/tests/global-config.test.ts +2 -9
- package/node_modules/zod/src/v4/classic/tests/hash.test.ts +1 -2
- package/node_modules/zod/src/v4/classic/tests/iban.test.ts +81 -0
- package/node_modules/zod/src/v4/classic/tests/in-out.test.ts +159 -0
- package/node_modules/zod/src/v4/classic/tests/index.test.ts +21 -2
- package/node_modules/zod/src/v4/classic/tests/instance-footprint.test.ts +319 -0
- package/node_modules/zod/src/v4/classic/tests/instanceof.test.ts +67 -0
- package/node_modules/zod/src/v4/classic/tests/intersection.test.ts +136 -0
- package/node_modules/zod/src/v4/classic/tests/issue-schema.test.ts +215 -0
- package/node_modules/zod/src/v4/classic/tests/jitless-allows-eval.test.ts +3 -10
- package/node_modules/zod/src/v4/classic/tests/lazy.test.ts +36 -1
- package/node_modules/zod/src/v4/classic/tests/literal.test.ts +12 -1
- package/node_modules/zod/src/v4/classic/tests/map.test.ts +12 -0
- package/node_modules/zod/src/v4/classic/tests/number.test.ts +85 -9
- package/node_modules/zod/src/v4/classic/tests/object.test.ts +301 -12
- package/node_modules/zod/src/v4/classic/tests/optin-ladder.test.ts +235 -0
- package/node_modules/zod/src/v4/classic/tests/optional.test.ts +49 -16
- package/node_modules/zod/src/v4/classic/tests/partial.test.ts +51 -4
- package/node_modules/zod/src/v4/classic/tests/prefault.test.ts +70 -0
- package/node_modules/zod/src/v4/classic/tests/preprocess-types.test.ts +20 -2
- package/node_modules/zod/src/v4/classic/tests/properties.test.ts +141 -0
- package/node_modules/zod/src/v4/classic/tests/readonly.test.ts +0 -68
- package/node_modules/zod/src/v4/classic/tests/record.test.ts +186 -18
- package/node_modules/zod/src/v4/classic/tests/recursive-types.test.ts +79 -3
- package/node_modules/zod/src/v4/classic/tests/redos.test.ts +68 -0
- package/node_modules/zod/src/v4/classic/tests/refine.test.ts +60 -0
- package/node_modules/zod/src/v4/classic/tests/set.test.ts +9 -0
- package/node_modules/zod/src/v4/classic/tests/standard-schema.test.ts +19 -0
- package/node_modules/zod/src/v4/classic/tests/string.test.ts +222 -6
- package/node_modules/zod/src/v4/classic/tests/stringbool.test.ts +18 -0
- package/node_modules/zod/src/v4/classic/tests/template-literal.test.ts +44 -3
- package/node_modules/zod/src/v4/classic/tests/to-json-schema.test.ts +1812 -204
- package/node_modules/zod/src/v4/classic/tests/tuple.test.ts +45 -30
- package/node_modules/zod/src/v4/classic/tests/union.test.ts +39 -2
- package/node_modules/zod/src/v4/classic/tests/validate.test.ts +645 -0
- package/node_modules/zod/src/v4/classic/tests/validations.test.ts +2 -2
- package/node_modules/zod/src/v4/core/api.ts +87 -35
- package/node_modules/zod/src/v4/core/checks.ts +119 -146
- package/node_modules/zod/src/v4/core/compile.ts +2313 -0
- package/node_modules/zod/src/v4/core/core.ts +99 -22
- package/node_modules/zod/src/v4/core/doc.ts +17 -9
- package/node_modules/zod/src/v4/core/errors.ts +113 -25
- package/node_modules/zod/src/v4/core/index.ts +3 -0
- package/node_modules/zod/src/v4/core/json-schema-generator.ts +8 -3
- package/node_modules/zod/src/v4/core/json-schema-processors.ts +424 -156
- package/node_modules/zod/src/v4/core/json-schema.ts +2 -1
- package/node_modules/zod/src/v4/core/memoizer.ts +331 -0
- package/node_modules/zod/src/v4/core/parse.ts +164 -50
- package/node_modules/zod/src/v4/core/regexes.ts +42 -15
- package/node_modules/zod/src/v4/core/registries.ts +2 -2
- package/node_modules/zod/src/v4/core/schemas.ts +1000 -538
- package/node_modules/zod/src/v4/core/tests/cached.test.ts +54 -0
- package/node_modules/zod/src/v4/core/tests/compile-differential.test.ts +1004 -0
- package/node_modules/zod/src/v4/core/tests/compile-generative.test.ts +445 -0
- package/node_modules/zod/src/v4/core/tests/compile-global.test.ts +89 -0
- package/node_modules/zod/src/v4/core/tests/compile-off-by-default.test.ts +26 -0
- package/node_modules/zod/src/v4/core/tests/compile-stats.test.ts +34 -0
- package/node_modules/zod/src/v4/core/tests/compile.test.ts +2036 -0
- package/node_modules/zod/src/v4/core/tests/email-regex.test.ts +140 -0
- package/node_modules/zod/src/v4/core/tests/locales/el.test.ts +1 -2
- package/node_modules/zod/src/v4/core/tests/locales/es.test.ts +1 -2
- package/node_modules/zod/src/v4/core/tests/locales/fr.test.ts +3 -3
- package/node_modules/zod/src/v4/core/tests/locales/parity.test.ts +42 -0
- package/node_modules/zod/src/v4/core/tests/locales/tg.test.ts +85 -0
- package/node_modules/zod/src/v4/core/tests/locales/tk.test.ts +69 -0
- package/node_modules/zod/src/v4/core/tests/polyfill-collision.test.ts +46 -0
- package/node_modules/zod/src/v4/core/tests/treeshake.test.ts +51 -0
- package/node_modules/zod/src/v4/core/tests/url-no-canparse.test.ts +133 -0
- package/node_modules/zod/src/v4/core/to-json-schema.ts +283 -48
- package/node_modules/zod/src/v4/core/util.ts +454 -157
- package/node_modules/zod/src/v4/core/versions.ts +2 -2
- package/node_modules/zod/src/v4/core/visit.ts +193 -0
- package/node_modules/zod/src/v4/index.ts +3 -3
- package/node_modules/zod/src/v4/locales/ar.ts +5 -0
- package/node_modules/zod/src/v4/locales/az.ts +5 -0
- package/node_modules/zod/src/v4/locales/be.ts +12 -0
- package/node_modules/zod/src/v4/locales/bg.ts +5 -0
- package/node_modules/zod/src/v4/locales/bn.ts +123 -0
- package/node_modules/zod/src/v4/locales/ca.ts +5 -0
- package/node_modules/zod/src/v4/locales/ckb.ts +140 -0
- package/node_modules/zod/src/v4/locales/cs.ts +5 -0
- package/node_modules/zod/src/v4/locales/da.ts +7 -2
- package/node_modules/zod/src/v4/locales/de.ts +5 -0
- package/node_modules/zod/src/v4/locales/el.ts +3 -0
- package/node_modules/zod/src/v4/locales/en.ts +17 -4
- package/node_modules/zod/src/v4/locales/eo.ts +5 -0
- package/node_modules/zod/src/v4/locales/es.ts +4 -0
- package/node_modules/zod/src/v4/locales/fa.ts +5 -0
- package/node_modules/zod/src/v4/locales/fi.ts +5 -0
- package/node_modules/zod/src/v4/locales/fr-CA.ts +5 -0
- package/node_modules/zod/src/v4/locales/fr.ts +21 -14
- package/node_modules/zod/src/v4/locales/gu.ts +123 -0
- package/node_modules/zod/src/v4/locales/he.ts +8 -1
- package/node_modules/zod/src/v4/locales/hi.ts +126 -0
- package/node_modules/zod/src/v4/locales/hr.ts +4 -0
- package/node_modules/zod/src/v4/locales/hu.ts +5 -0
- package/node_modules/zod/src/v4/locales/hy.ts +11 -0
- package/node_modules/zod/src/v4/locales/id.ts +5 -0
- package/node_modules/zod/src/v4/locales/index.ts +11 -0
- package/node_modules/zod/src/v4/locales/is.ts +5 -0
- package/node_modules/zod/src/v4/locales/it.ts +5 -0
- package/node_modules/zod/src/v4/locales/ja.ts +5 -0
- package/node_modules/zod/src/v4/locales/ka.ts +5 -0
- package/node_modules/zod/src/v4/locales/km.ts +5 -0
- package/node_modules/zod/src/v4/locales/kn.ts +126 -0
- package/node_modules/zod/src/v4/locales/ko.ts +5 -0
- package/node_modules/zod/src/v4/locales/lt.ts +4 -0
- package/node_modules/zod/src/v4/locales/mk.ts +5 -0
- package/node_modules/zod/src/v4/locales/ms.ts +5 -0
- package/node_modules/zod/src/v4/locales/ne.ts +128 -0
- package/node_modules/zod/src/v4/locales/nl.ts +5 -0
- package/node_modules/zod/src/v4/locales/nn.ts +121 -0
- package/node_modules/zod/src/v4/locales/no.ts +7 -2
- package/node_modules/zod/src/v4/locales/ota.ts +5 -0
- package/node_modules/zod/src/v4/locales/pl.ts +5 -0
- package/node_modules/zod/src/v4/locales/ps.ts +5 -0
- package/node_modules/zod/src/v4/locales/pt-BR.ts +161 -0
- package/node_modules/zod/src/v4/locales/pt.ts +101 -58
- package/node_modules/zod/src/v4/locales/ro.ts +3 -0
- package/node_modules/zod/src/v4/locales/ru.ts +12 -0
- package/node_modules/zod/src/v4/locales/sk.ts +123 -0
- package/node_modules/zod/src/v4/locales/sl.ts +5 -0
- package/node_modules/zod/src/v4/locales/sv.ts +7 -2
- package/node_modules/zod/src/v4/locales/ta.ts +5 -0
- package/node_modules/zod/src/v4/locales/tg.ts +135 -0
- package/node_modules/zod/src/v4/locales/th.ts +5 -0
- package/node_modules/zod/src/v4/locales/tk.ts +113 -0
- package/node_modules/zod/src/v4/locales/tr.ts +5 -0
- package/node_modules/zod/src/v4/locales/uk.ts +5 -0
- package/node_modules/zod/src/v4/locales/ur.ts +5 -0
- package/node_modules/zod/src/v4/locales/uz.ts +3 -0
- package/node_modules/zod/src/v4/locales/vi.ts +5 -0
- package/node_modules/zod/src/v4/locales/yo.ts +5 -0
- package/node_modules/zod/src/v4/locales/zh-CN.ts +5 -0
- package/node_modules/zod/src/v4/locales/zh-TW.ts +5 -0
- package/node_modules/zod/src/v4/mini/checks.ts +1 -0
- package/node_modules/zod/src/v4/mini/deep-partial.ts +73 -0
- package/node_modules/zod/src/v4/mini/external.ts +12 -1
- package/node_modules/zod/src/v4/mini/in-out.ts +45 -0
- package/node_modules/zod/src/v4/mini/parse.ts +2 -0
- package/node_modules/zod/src/v4/mini/schemas.ts +167 -63
- package/node_modules/zod/src/v4/mini/tests/apply.test.ts +33 -0
- package/node_modules/zod/src/v4/mini/tests/assignability.test.ts +62 -1
- package/node_modules/zod/src/v4/mini/tests/checks.test.ts +14 -0
- package/node_modules/zod/src/v4/mini/tests/codec.test.ts +35 -1
- package/node_modules/zod/src/v4/mini/tests/computed.test.ts +11 -17
- package/node_modules/zod/src/v4/mini/tests/cyclic-data.test.ts +84 -0
- package/node_modules/zod/src/v4/mini/tests/deep-partial.test.ts +54 -0
- package/node_modules/zod/src/v4/mini/tests/error.test.ts +23 -4
- package/node_modules/zod/src/v4/mini/tests/functions.test.ts +9 -0
- package/node_modules/zod/src/v4/mini/tests/index.test.ts +158 -5
- package/node_modules/zod/src/v4/mini/tests/number.test.ts +14 -0
- package/node_modules/zod/src/v4/mini/tests/object.test.ts +65 -0
- package/node_modules/zod/src/v4/mini/tests/recursive-types.test.ts +16 -0
- package/node_modules/zod/src/v4/mini/tests/string.test.ts +44 -0
- package/node_modules/zod/v3/ZodError.cjs +41 -12
- package/node_modules/zod/v3/ZodError.d.cts +1 -1
- package/node_modules/zod/v3/ZodError.d.ts +1 -1
- package/node_modules/zod/v3/ZodError.js +22 -12
- package/node_modules/zod/v3/errors.cjs +19 -0
- package/node_modules/zod/v3/external.cjs +19 -0
- package/node_modules/zod/v3/helpers/enumUtil.cjs +19 -0
- package/node_modules/zod/v3/helpers/errorUtil.cjs +20 -1
- package/node_modules/zod/v3/helpers/errorUtil.js +1 -1
- package/node_modules/zod/v3/helpers/parseUtil.cjs +19 -0
- package/node_modules/zod/v3/helpers/partialUtil.cjs +19 -0
- package/node_modules/zod/v3/helpers/typeAliases.cjs +19 -0
- package/node_modules/zod/v3/helpers/util.cjs +19 -0
- package/node_modules/zod/v3/index.cjs +19 -0
- package/node_modules/zod/v3/standard-schema.cjs +19 -0
- package/node_modules/zod/v3/types.cjs +26 -5
- package/node_modules/zod/v3/types.js +7 -5
- package/node_modules/zod/v4/classic/checks.cjs +21 -1
- package/node_modules/zod/v4/classic/checks.d.cts +1 -1
- package/node_modules/zod/v4/classic/checks.d.ts +1 -1
- package/node_modules/zod/v4/classic/checks.js +1 -1
- package/node_modules/zod/v4/classic/coerce.cjs +19 -0
- package/node_modules/zod/v4/classic/compat.cjs +19 -0
- package/node_modules/zod/v4/classic/compat.d.cts +9 -11
- package/node_modules/zod/v4/classic/compat.d.ts +9 -11
- package/node_modules/zod/v4/classic/deep-partial.cjs +58 -0
- package/node_modules/zod/v4/classic/deep-partial.d.cts +14 -0
- package/node_modules/zod/v4/classic/deep-partial.d.ts +14 -0
- package/node_modules/zod/v4/classic/deep-partial.js +13 -0
- package/node_modules/zod/v4/classic/errors.cjs +62 -34
- package/node_modules/zod/v4/classic/errors.d.cts +3 -4
- package/node_modules/zod/v4/classic/errors.d.ts +3 -4
- package/node_modules/zod/v4/classic/errors.js +43 -34
- package/node_modules/zod/v4/classic/external.cjs +51 -27
- package/node_modules/zod/v4/classic/external.d.cts +5 -2
- package/node_modules/zod/v4/classic/external.d.ts +5 -2
- package/node_modules/zod/v4/classic/external.js +5 -8
- package/node_modules/zod/v4/classic/from-json-schema.cjs +376 -75
- package/node_modules/zod/v4/classic/from-json-schema.js +357 -75
- package/node_modules/zod/v4/classic/in-out.cjs +82 -0
- package/node_modules/zod/v4/classic/in-out.d.cts +8 -0
- package/node_modules/zod/v4/classic/in-out.d.ts +8 -0
- package/node_modules/zod/v4/classic/in-out.js +36 -0
- package/node_modules/zod/v4/classic/index.cjs +21 -2
- package/node_modules/zod/v4/classic/index.d.cts +1 -2
- package/node_modules/zod/v4/classic/index.d.ts +1 -2
- package/node_modules/zod/v4/classic/index.js +2 -2
- package/node_modules/zod/v4/classic/iso.cjs +30 -22
- package/node_modules/zod/v4/classic/iso.d.cts +2 -17
- package/node_modules/zod/v4/classic/iso.d.ts +2 -17
- package/node_modules/zod/v4/classic/iso.js +2 -17
- package/node_modules/zod/v4/classic/parse.cjs +23 -1
- package/node_modules/zod/v4/classic/parse.d.cts +17 -4
- package/node_modules/zod/v4/classic/parse.d.ts +17 -4
- package/node_modules/zod/v4/classic/parse.js +1 -0
- package/node_modules/zod/v4/classic/schemas.cjs +591 -426
- package/node_modules/zod/v4/classic/schemas.d.cts +68 -19
- package/node_modules/zod/v4/classic/schemas.d.ts +68 -19
- package/node_modules/zod/v4/classic/schemas.js +564 -424
- package/node_modules/zod/v4/core/api.cjs +66 -24
- package/node_modules/zod/v4/core/api.d.cts +22 -12
- package/node_modules/zod/v4/core/api.d.ts +22 -12
- package/node_modules/zod/v4/core/api.js +44 -24
- package/node_modules/zod/v4/core/checks.cjs +88 -128
- package/node_modules/zod/v4/core/checks.d.cts +29 -13
- package/node_modules/zod/v4/core/checks.d.ts +29 -13
- package/node_modules/zod/v4/core/checks.js +68 -127
- package/node_modules/zod/v4/core/compile.cjs +1908 -0
- package/node_modules/zod/v4/core/compile.d.cts +65 -0
- package/node_modules/zod/v4/core/compile.d.ts +65 -0
- package/node_modules/zod/v4/core/compile.js +1858 -0
- package/node_modules/zod/v4/core/core.cjs +101 -19
- package/node_modules/zod/v4/core/core.d.cts +16 -4
- package/node_modules/zod/v4/core/core.d.ts +16 -4
- package/node_modules/zod/v4/core/core.js +83 -20
- package/node_modules/zod/v4/core/doc.cjs +31 -9
- package/node_modules/zod/v4/core/doc.d.cts +3 -1
- package/node_modules/zod/v4/core/doc.d.ts +3 -1
- package/node_modules/zod/v4/core/doc.js +12 -9
- package/node_modules/zod/v4/core/errors.cjs +126 -25
- package/node_modules/zod/v4/core/errors.d.cts +4 -0
- package/node_modules/zod/v4/core/errors.d.ts +4 -0
- package/node_modules/zod/v4/core/errors.js +107 -25
- package/node_modules/zod/v4/core/index.cjs +24 -1
- package/node_modules/zod/v4/core/index.d.cts +3 -0
- package/node_modules/zod/v4/core/index.d.ts +3 -0
- package/node_modules/zod/v4/core/index.js +3 -0
- package/node_modules/zod/v4/core/json-schema-generator.cjs +24 -1
- package/node_modules/zod/v4/core/json-schema-generator.d.cts +2 -2
- package/node_modules/zod/v4/core/json-schema-generator.d.ts +2 -2
- package/node_modules/zod/v4/core/json-schema-generator.js +6 -2
- package/node_modules/zod/v4/core/json-schema-processors.cjs +441 -156
- package/node_modules/zod/v4/core/json-schema-processors.d.cts +16 -0
- package/node_modules/zod/v4/core/json-schema-processors.d.ts +16 -0
- package/node_modules/zod/v4/core/json-schema-processors.js +400 -158
- package/node_modules/zod/v4/core/json-schema.cjs +19 -0
- package/node_modules/zod/v4/core/json-schema.d.cts +2 -1
- package/node_modules/zod/v4/core/json-schema.d.ts +2 -1
- package/node_modules/zod/v4/core/memoizer.cjs +360 -0
- package/node_modules/zod/v4/core/memoizer.d.cts +15 -0
- package/node_modules/zod/v4/core/memoizer.d.ts +15 -0
- package/node_modules/zod/v4/core/memoizer.js +311 -0
- package/node_modules/zod/v4/core/parse.cjs +148 -46
- package/node_modules/zod/v4/core/parse.d.cts +14 -11
- package/node_modules/zod/v4/core/parse.d.ts +14 -11
- package/node_modules/zod/v4/core/parse.js +127 -45
- package/node_modules/zod/v4/core/regexes.cjs +54 -17
- package/node_modules/zod/v4/core/regexes.d.cts +5 -0
- package/node_modules/zod/v4/core/regexes.d.ts +5 -0
- package/node_modules/zod/v4/core/regexes.js +32 -15
- package/node_modules/zod/v4/core/registries.cjs +19 -0
- package/node_modules/zod/v4/core/registries.js +2 -2
- package/node_modules/zod/v4/core/schemas.cjs +785 -386
- package/node_modules/zod/v4/core/schemas.d.cts +123 -34
- package/node_modules/zod/v4/core/schemas.d.ts +123 -34
- package/node_modules/zod/v4/core/schemas.js +753 -386
- package/node_modules/zod/v4/core/standard-schema.cjs +19 -0
- package/node_modules/zod/v4/core/to-json-schema.cjs +269 -45
- package/node_modules/zod/v4/core/to-json-schema.d.cts +45 -5
- package/node_modules/zod/v4/core/to-json-schema.d.ts +45 -5
- package/node_modules/zod/v4/core/to-json-schema.js +247 -44
- package/node_modules/zod/v4/core/util.cjs +372 -157
- package/node_modules/zod/v4/core/util.d.cts +79 -1
- package/node_modules/zod/v4/core/util.d.ts +79 -1
- package/node_modules/zod/v4/core/util.js +341 -156
- package/node_modules/zod/v4/core/versions.cjs +21 -2
- package/node_modules/zod/v4/core/versions.d.cts +1 -1
- package/node_modules/zod/v4/core/versions.d.ts +1 -1
- package/node_modules/zod/v4/core/versions.js +2 -2
- package/node_modules/zod/v4/core/visit.cjs +214 -0
- package/node_modules/zod/v4/core/visit.d.cts +30 -0
- package/node_modules/zod/v4/core/visit.d.ts +30 -0
- package/node_modules/zod/v4/core/visit.js +169 -0
- package/node_modules/zod/v4/index.cjs +34 -5
- package/node_modules/zod/v4/index.d.cts +2 -2
- package/node_modules/zod/v4/index.d.ts +2 -2
- package/node_modules/zod/v4/index.js +3 -2
- package/node_modules/zod/v4/locales/ar.cjs +5 -0
- package/node_modules/zod/v4/locales/ar.js +5 -0
- package/node_modules/zod/v4/locales/az.cjs +5 -0
- package/node_modules/zod/v4/locales/az.js +5 -0
- package/node_modules/zod/v4/locales/be.cjs +12 -0
- package/node_modules/zod/v4/locales/be.js +12 -0
- package/node_modules/zod/v4/locales/bg.cjs +5 -0
- package/node_modules/zod/v4/locales/bg.js +5 -0
- package/node_modules/zod/v4/locales/bn.cjs +140 -0
- package/node_modules/zod/v4/locales/bn.d.cts +5 -0
- package/node_modules/zod/v4/locales/bn.d.ts +4 -0
- package/node_modules/zod/v4/locales/bn.js +113 -0
- package/node_modules/zod/v4/locales/ca.cjs +5 -0
- package/node_modules/zod/v4/locales/ca.js +5 -0
- package/node_modules/zod/v4/locales/ckb.cjs +160 -0
- package/node_modules/zod/v4/locales/ckb.d.cts +5 -0
- package/node_modules/zod/v4/locales/ckb.d.ts +4 -0
- package/node_modules/zod/v4/locales/ckb.js +133 -0
- package/node_modules/zod/v4/locales/cs.cjs +5 -0
- package/node_modules/zod/v4/locales/cs.js +5 -0
- package/node_modules/zod/v4/locales/da.cjs +7 -2
- package/node_modules/zod/v4/locales/da.js +7 -2
- package/node_modules/zod/v4/locales/de.cjs +5 -0
- package/node_modules/zod/v4/locales/de.js +5 -0
- package/node_modules/zod/v4/locales/el.cjs +3 -0
- package/node_modules/zod/v4/locales/el.js +3 -0
- package/node_modules/zod/v4/locales/en.cjs +16 -4
- package/node_modules/zod/v4/locales/en.js +16 -4
- package/node_modules/zod/v4/locales/eo.cjs +5 -0
- package/node_modules/zod/v4/locales/eo.js +5 -0
- package/node_modules/zod/v4/locales/es.cjs +4 -0
- package/node_modules/zod/v4/locales/es.js +4 -0
- package/node_modules/zod/v4/locales/fa.cjs +5 -0
- package/node_modules/zod/v4/locales/fa.js +5 -0
- package/node_modules/zod/v4/locales/fi.cjs +5 -0
- package/node_modules/zod/v4/locales/fi.js +5 -0
- package/node_modules/zod/v4/locales/fr-CA.cjs +5 -0
- package/node_modules/zod/v4/locales/fr-CA.js +5 -0
- package/node_modules/zod/v4/locales/fr.cjs +18 -14
- package/node_modules/zod/v4/locales/fr.js +18 -14
- package/node_modules/zod/v4/locales/gu.cjs +140 -0
- package/node_modules/zod/v4/locales/gu.d.cts +5 -0
- package/node_modules/zod/v4/locales/gu.d.ts +4 -0
- package/node_modules/zod/v4/locales/gu.js +113 -0
- package/node_modules/zod/v4/locales/he.cjs +7 -0
- package/node_modules/zod/v4/locales/he.js +7 -0
- package/node_modules/zod/v4/locales/hi.cjs +138 -0
- package/node_modules/zod/v4/locales/hi.d.cts +5 -0
- package/node_modules/zod/v4/locales/hi.d.ts +4 -0
- package/node_modules/zod/v4/locales/hi.js +111 -0
- package/node_modules/zod/v4/locales/hr.cjs +4 -0
- package/node_modules/zod/v4/locales/hr.js +4 -0
- package/node_modules/zod/v4/locales/hu.cjs +5 -0
- package/node_modules/zod/v4/locales/hu.js +5 -0
- package/node_modules/zod/v4/locales/hy.cjs +11 -0
- package/node_modules/zod/v4/locales/hy.js +11 -0
- package/node_modules/zod/v4/locales/id.cjs +5 -0
- package/node_modules/zod/v4/locales/id.js +5 -0
- package/node_modules/zod/v4/locales/index.cjs +43 -2
- package/node_modules/zod/v4/locales/index.d.cts +11 -0
- package/node_modules/zod/v4/locales/index.d.ts +11 -0
- package/node_modules/zod/v4/locales/index.js +11 -0
- package/node_modules/zod/v4/locales/is.cjs +5 -0
- package/node_modules/zod/v4/locales/is.js +5 -0
- package/node_modules/zod/v4/locales/it.cjs +5 -0
- package/node_modules/zod/v4/locales/it.js +5 -0
- package/node_modules/zod/v4/locales/ja.cjs +5 -0
- package/node_modules/zod/v4/locales/ja.js +5 -0
- package/node_modules/zod/v4/locales/ka.cjs +5 -0
- package/node_modules/zod/v4/locales/ka.js +5 -0
- package/node_modules/zod/v4/locales/km.cjs +5 -0
- package/node_modules/zod/v4/locales/km.js +5 -0
- package/node_modules/zod/v4/locales/kn.cjs +143 -0
- package/node_modules/zod/v4/locales/kn.d.cts +5 -0
- package/node_modules/zod/v4/locales/kn.d.ts +4 -0
- package/node_modules/zod/v4/locales/kn.js +116 -0
- package/node_modules/zod/v4/locales/ko.cjs +5 -0
- package/node_modules/zod/v4/locales/ko.js +5 -0
- package/node_modules/zod/v4/locales/lt.cjs +4 -0
- package/node_modules/zod/v4/locales/lt.js +4 -0
- package/node_modules/zod/v4/locales/mk.cjs +5 -0
- package/node_modules/zod/v4/locales/mk.js +5 -0
- package/node_modules/zod/v4/locales/ms.cjs +5 -0
- package/node_modules/zod/v4/locales/ms.js +5 -0
- package/node_modules/zod/v4/locales/ne.cjs +138 -0
- package/node_modules/zod/v4/locales/ne.d.cts +5 -0
- package/node_modules/zod/v4/locales/ne.d.ts +4 -0
- package/node_modules/zod/v4/locales/ne.js +111 -0
- package/node_modules/zod/v4/locales/nl.cjs +5 -0
- package/node_modules/zod/v4/locales/nl.js +5 -0
- package/node_modules/zod/v4/locales/nn.cjs +140 -0
- package/node_modules/zod/v4/locales/nn.d.cts +5 -0
- package/node_modules/zod/v4/locales/nn.d.ts +4 -0
- package/node_modules/zod/v4/locales/nn.js +113 -0
- package/node_modules/zod/v4/locales/no.cjs +7 -2
- package/node_modules/zod/v4/locales/no.js +7 -2
- package/node_modules/zod/v4/locales/ota.cjs +5 -0
- package/node_modules/zod/v4/locales/ota.js +5 -0
- package/node_modules/zod/v4/locales/pl.cjs +5 -0
- package/node_modules/zod/v4/locales/pl.js +5 -0
- package/node_modules/zod/v4/locales/ps.cjs +5 -0
- package/node_modules/zod/v4/locales/ps.js +5 -0
- package/node_modules/zod/v4/locales/pt-BR.cjs +170 -0
- package/node_modules/zod/v4/locales/pt-BR.d.cts +5 -0
- package/node_modules/zod/v4/locales/pt-BR.d.ts +4 -0
- package/node_modules/zod/v4/locales/pt-BR.js +143 -0
- package/node_modules/zod/v4/locales/pt.cjs +89 -55
- package/node_modules/zod/v4/locales/pt.js +89 -55
- package/node_modules/zod/v4/locales/ro.cjs +3 -0
- package/node_modules/zod/v4/locales/ro.js +3 -0
- package/node_modules/zod/v4/locales/ru.cjs +12 -0
- package/node_modules/zod/v4/locales/ru.js +12 -0
- package/node_modules/zod/v4/locales/sk.cjs +143 -0
- package/node_modules/zod/v4/locales/sk.d.cts +5 -0
- package/node_modules/zod/v4/locales/sk.d.ts +4 -0
- package/node_modules/zod/v4/locales/sk.js +116 -0
- package/node_modules/zod/v4/locales/sl.cjs +5 -0
- package/node_modules/zod/v4/locales/sl.js +5 -0
- package/node_modules/zod/v4/locales/sv.cjs +7 -2
- package/node_modules/zod/v4/locales/sv.js +7 -2
- package/node_modules/zod/v4/locales/ta.cjs +5 -0
- package/node_modules/zod/v4/locales/ta.js +5 -0
- package/node_modules/zod/v4/locales/tg.cjs +144 -0
- package/node_modules/zod/v4/locales/tg.d.cts +5 -0
- package/node_modules/zod/v4/locales/tg.d.ts +4 -0
- package/node_modules/zod/v4/locales/tg.js +117 -0
- package/node_modules/zod/v4/locales/th.cjs +5 -0
- package/node_modules/zod/v4/locales/th.js +5 -0
- package/node_modules/zod/v4/locales/tk.cjs +134 -0
- package/node_modules/zod/v4/locales/tk.d.cts +5 -0
- package/node_modules/zod/v4/locales/tk.d.ts +4 -0
- package/node_modules/zod/v4/locales/tk.js +107 -0
- package/node_modules/zod/v4/locales/tr.cjs +5 -0
- package/node_modules/zod/v4/locales/tr.js +5 -0
- package/node_modules/zod/v4/locales/uk.cjs +5 -0
- package/node_modules/zod/v4/locales/uk.js +5 -0
- package/node_modules/zod/v4/locales/ur.cjs +5 -0
- package/node_modules/zod/v4/locales/ur.js +5 -0
- package/node_modules/zod/v4/locales/uz.cjs +3 -0
- package/node_modules/zod/v4/locales/uz.js +3 -0
- package/node_modules/zod/v4/locales/vi.cjs +5 -0
- package/node_modules/zod/v4/locales/vi.js +5 -0
- package/node_modules/zod/v4/locales/yo.cjs +5 -0
- package/node_modules/zod/v4/locales/yo.js +5 -0
- package/node_modules/zod/v4/locales/zh-CN.cjs +5 -0
- package/node_modules/zod/v4/locales/zh-CN.js +5 -0
- package/node_modules/zod/v4/locales/zh-TW.cjs +5 -0
- package/node_modules/zod/v4/locales/zh-TW.js +5 -0
- package/node_modules/zod/v4/mini/checks.cjs +21 -1
- package/node_modules/zod/v4/mini/checks.d.cts +1 -1
- package/node_modules/zod/v4/mini/checks.d.ts +1 -1
- package/node_modules/zod/v4/mini/checks.js +1 -1
- package/node_modules/zod/v4/mini/coerce.cjs +19 -0
- package/node_modules/zod/v4/mini/deep-partial.cjs +58 -0
- package/node_modules/zod/v4/mini/deep-partial.d.cts +14 -0
- package/node_modules/zod/v4/mini/deep-partial.d.ts +14 -0
- package/node_modules/zod/v4/mini/deep-partial.js +13 -0
- package/node_modules/zod/v4/mini/external.cjs +33 -1
- package/node_modules/zod/v4/mini/external.d.cts +5 -2
- package/node_modules/zod/v4/mini/external.d.ts +5 -2
- package/node_modules/zod/v4/mini/external.js +3 -1
- package/node_modules/zod/v4/mini/in-out.cjs +82 -0
- package/node_modules/zod/v4/mini/in-out.d.cts +8 -0
- package/node_modules/zod/v4/mini/in-out.d.ts +8 -0
- package/node_modules/zod/v4/mini/in-out.js +36 -0
- package/node_modules/zod/v4/mini/index.cjs +19 -0
- package/node_modules/zod/v4/mini/iso.cjs +19 -0
- package/node_modules/zod/v4/mini/parse.cjs +22 -1
- package/node_modules/zod/v4/mini/parse.d.cts +1 -1
- package/node_modules/zod/v4/mini/parse.d.ts +1 -1
- package/node_modules/zod/v4/mini/parse.js +1 -1
- package/node_modules/zod/v4/mini/schemas.cjs +117 -53
- package/node_modules/zod/v4/mini/schemas.d.cts +49 -14
- package/node_modules/zod/v4/mini/schemas.d.ts +49 -14
- package/node_modules/zod/v4/mini/schemas.js +92 -51
- package/node_modules/zod/v4-mini/index.cjs +19 -0
- package/openclaw.plugin.json +1 -2
- package/package.json +8 -6
- package/node_modules/zod/src/v4/core/config.ts +0 -15
- /package/dist/{secret-contract-BKkzzjBA.js → .setup/secret-contract-BKkzzjBA.mjs} +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { b as resolveClickClackAccount, d as isClickClackChannelNameConflict, l as ClickClackHttpError, u as createClickClackClient, v as listClickClackAccountIds } from "./setup-surface-
|
|
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-
|
|
3
|
-
import "
|
|
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-CT4CVd4d.mjs";
|
|
3
|
+
import "../api.js";
|
|
4
4
|
import { randomUUID } from "node:crypto";
|
|
5
5
|
import { buildControlUiSessionPath, registerSessionDiscussionProvider } from "openclaw/plugin-sdk/session-discussion";
|
|
6
6
|
import { createSessionVisibilityChecker } from "openclaw/plugin-sdk/session-visibility";
|
|
@@ -95,17 +95,19 @@ function formatDiscussionHistory(history) {
|
|
|
95
95
|
const INSTALLATION_NAMESPACE = "discussion-installation";
|
|
96
96
|
const INSTALLATION_KEY = "current";
|
|
97
97
|
/** Returns the durable installation namespace used in server-visible ownership refs. */
|
|
98
|
-
function getClickClackDiscussionInstallationId(runtime) {
|
|
99
|
-
const store = runtime.state.
|
|
98
|
+
async function getClickClackDiscussionInstallationId(runtime) {
|
|
99
|
+
const store = runtime.state.openKeyedStore({
|
|
100
100
|
namespace: INSTALLATION_NAMESPACE,
|
|
101
101
|
maxEntries: 1,
|
|
102
102
|
overflowPolicy: "reject-new"
|
|
103
103
|
});
|
|
104
|
-
const existing = store.lookup(INSTALLATION_KEY)?.id;
|
|
104
|
+
const existing = (await store.lookup(INSTALLATION_KEY))?.id;
|
|
105
105
|
if (existing) return existing;
|
|
106
106
|
const id = randomUUID();
|
|
107
|
-
store.registerIfAbsent(INSTALLATION_KEY, { id });
|
|
108
|
-
|
|
107
|
+
await store.registerIfAbsent(INSTALLATION_KEY, { id });
|
|
108
|
+
const persisted = (await store.lookup(INSTALLATION_KEY))?.id;
|
|
109
|
+
if (!persisted) throw new Error("ClickClack discussion installation identity is unavailable; retry opening the discussion");
|
|
110
|
+
return persisted;
|
|
109
111
|
}
|
|
110
112
|
//#endregion
|
|
111
113
|
//#region extensions/clickclack/src/discussions/reconcile-scheduler.ts
|
|
@@ -251,10 +253,10 @@ async function openClickClackDiscussionBinding(params) {
|
|
|
251
253
|
if (!workspace.route_id) throw new Error("ClickClack discussions workspace is missing its route id");
|
|
252
254
|
const serverBaseUrl = normalizedServerBaseUrl(account);
|
|
253
255
|
const credentialFingerprint = discussionCredentialFingerprint(account.token);
|
|
254
|
-
const unresolved = listPendingDiscussionOpens(runtime).find((pending) => pending.sessionKey === sessionKey);
|
|
256
|
+
const unresolved = (await listPendingDiscussionOpens(runtime)).find((pending) => pending.sessionKey === sessionKey);
|
|
255
257
|
if (unresolved && (unresolved.accountId !== account.accountId || unresolved.credentialFingerprint !== credentialFingerprint || unresolved.serverBaseUrl !== serverBaseUrl || unresolved.workspaceId !== workspace.id)) {
|
|
256
258
|
await params.reconcilePendingOpen(unresolved);
|
|
257
|
-
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");
|
|
258
260
|
}
|
|
259
261
|
const config = runtime.config.current();
|
|
260
262
|
const agentId = resolveSessionAgentIdStrict({
|
|
@@ -266,12 +268,21 @@ async function openClickClackDiscussionBinding(params) {
|
|
|
266
268
|
const displayTitle = label === fallback ? "" : truncateDiscussionDisplayTitle(label);
|
|
267
269
|
const section = entry.category?.trim() || account.discussions.section;
|
|
268
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
|
+
};
|
|
269
280
|
return await params.withChannelMutationLock(async () => {
|
|
270
281
|
params.ensureBindingCapacity(sessionKey);
|
|
271
282
|
let channels = await client.channels(workspace.id);
|
|
272
283
|
assertManagedChannelListContract(channels);
|
|
273
284
|
const destinationIdentity = [serverBaseUrl, workspace.id].join("\0");
|
|
274
|
-
const bindingGeneration = reserveDiscussionBindingGeneration({
|
|
285
|
+
const bindingGeneration = await reserveDiscussionBindingGeneration({
|
|
275
286
|
runtime,
|
|
276
287
|
sessionKey,
|
|
277
288
|
accountId: account.accountId,
|
|
@@ -301,7 +312,7 @@ async function openClickClackDiscussionBinding(params) {
|
|
|
301
312
|
sidebar_section: section,
|
|
302
313
|
display_title: displayTitle
|
|
303
314
|
};
|
|
304
|
-
recordPendingDiscussionOpen({
|
|
315
|
+
await recordPendingDiscussionOpen({
|
|
305
316
|
runtime,
|
|
306
317
|
sessionKey,
|
|
307
318
|
generation: bindingGeneration,
|
|
@@ -314,7 +325,8 @@ async function openClickClackDiscussionBinding(params) {
|
|
|
314
325
|
credentialFingerprint
|
|
315
326
|
}
|
|
316
327
|
});
|
|
317
|
-
params.ensureTimer();
|
|
328
|
+
await params.ensureTimer();
|
|
329
|
+
assertCurrentAuthority();
|
|
318
330
|
try {
|
|
319
331
|
if (adopted) {
|
|
320
332
|
markClickClackDiscussionChannelIdentityRevoked({
|
|
@@ -356,16 +368,17 @@ async function openClickClackDiscussionBinding(params) {
|
|
|
356
368
|
serverBaseUrl,
|
|
357
369
|
channelId: recovered.id
|
|
358
370
|
});
|
|
371
|
+
assertCurrentAuthority();
|
|
359
372
|
resolved = await client.updateChannel(recovered.id, managedFields);
|
|
360
373
|
break;
|
|
361
374
|
}
|
|
362
|
-
if (definitiveNoCreate) clearDiscussionBindingGeneration({
|
|
375
|
+
if (definitiveNoCreate) await clearDiscussionBindingGeneration({
|
|
363
376
|
runtime,
|
|
364
377
|
sessionKey,
|
|
365
378
|
expectedGeneration: bindingGeneration
|
|
366
379
|
});
|
|
367
380
|
} catch {
|
|
368
|
-
if (definitiveNoCreate && !adopted) clearDiscussionBindingGeneration({
|
|
381
|
+
if (definitiveNoCreate && !adopted) await clearDiscussionBindingGeneration({
|
|
369
382
|
runtime,
|
|
370
383
|
sessionKey,
|
|
371
384
|
expectedGeneration: bindingGeneration
|
|
@@ -385,7 +398,7 @@ async function openClickClackDiscussionBinding(params) {
|
|
|
385
398
|
});
|
|
386
399
|
if (adopted) assertChannelPatch(resolved, managedFields);
|
|
387
400
|
} catch (error) {
|
|
388
|
-
clearPendingDiscussionOpen({
|
|
401
|
+
await clearPendingDiscussionOpen({
|
|
389
402
|
runtime,
|
|
390
403
|
sessionKey,
|
|
391
404
|
expectedGeneration: bindingGeneration
|
|
@@ -394,7 +407,7 @@ async function openClickClackDiscussionBinding(params) {
|
|
|
394
407
|
throw error;
|
|
395
408
|
}
|
|
396
409
|
if (!resolved.route_id) {
|
|
397
|
-
clearPendingDiscussionOpen({
|
|
410
|
+
await clearPendingDiscussionOpen({
|
|
398
411
|
runtime,
|
|
399
412
|
sessionKey,
|
|
400
413
|
expectedGeneration: bindingGeneration
|
|
@@ -408,7 +421,7 @@ async function openClickClackDiscussionBinding(params) {
|
|
|
408
421
|
readConsistency: "latest"
|
|
409
422
|
});
|
|
410
423
|
if (!currentEntry?.sessionId || currentEntry.archivedAt !== void 0) {
|
|
411
|
-
clearPendingDiscussionOpen({
|
|
424
|
+
await clearPendingDiscussionOpen({
|
|
412
425
|
runtime,
|
|
413
426
|
sessionKey,
|
|
414
427
|
expectedGeneration: bindingGeneration
|
|
@@ -438,6 +451,7 @@ async function openClickClackDiscussionBinding(params) {
|
|
|
438
451
|
display_title: currentDisplayTitle
|
|
439
452
|
};
|
|
440
453
|
try {
|
|
454
|
+
assertCurrentAuthority();
|
|
441
455
|
currentChannel = await client.updateChannel(channel.id, latestManagedFields);
|
|
442
456
|
assertChannelPatch(currentChannel, latestManagedFields);
|
|
443
457
|
break;
|
|
@@ -446,7 +460,7 @@ async function openClickClackDiscussionBinding(params) {
|
|
|
446
460
|
}
|
|
447
461
|
}
|
|
448
462
|
} catch (error) {
|
|
449
|
-
clearPendingDiscussionOpen({
|
|
463
|
+
await clearPendingDiscussionOpen({
|
|
450
464
|
runtime,
|
|
451
465
|
sessionKey,
|
|
452
466
|
expectedGeneration: bindingGeneration
|
|
@@ -473,9 +487,10 @@ async function openClickClackDiscussionBinding(params) {
|
|
|
473
487
|
...currentChannel.display_title !== void 0 ? { displayTitle: currentChannel.display_title } : {}
|
|
474
488
|
};
|
|
475
489
|
try {
|
|
490
|
+
assertCurrentAuthority();
|
|
476
491
|
store.set(sessionKey, nextBinding);
|
|
477
492
|
} catch (error) {
|
|
478
|
-
clearPendingDiscussionOpen({
|
|
493
|
+
await clearPendingDiscussionOpen({
|
|
479
494
|
runtime,
|
|
480
495
|
sessionKey,
|
|
481
496
|
expectedGeneration: bindingGeneration
|
|
@@ -483,10 +498,59 @@ async function openClickClackDiscussionBinding(params) {
|
|
|
483
498
|
params.warn(`unbound discussion channel remains quarantined: ${channel.id}`);
|
|
484
499
|
throw error;
|
|
485
500
|
}
|
|
486
|
-
params.finalizePendingBinding(sessionKey, nextBinding);
|
|
501
|
+
await params.finalizePendingBinding(sessionKey, nextBinding);
|
|
487
502
|
return nextBinding;
|
|
488
503
|
});
|
|
489
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
|
+
}
|
|
490
554
|
//#endregion
|
|
491
555
|
//#region extensions/clickclack/src/discussions/service.ts
|
|
492
556
|
const RECONCILE_INTERVAL_MS = 6e4;
|
|
@@ -501,7 +565,7 @@ var ClickClackDiscussionService = class {
|
|
|
501
565
|
#timersEnabled;
|
|
502
566
|
#sessionLocks = /* @__PURE__ */ new Map();
|
|
503
567
|
#reconcileScheduler = new DiscussionReconcileScheduler({
|
|
504
|
-
shouldSchedule: (
|
|
568
|
+
shouldSchedule: () => !this.#closed,
|
|
505
569
|
run: async (sessionKey) => await this.reconcile(sessionKey),
|
|
506
570
|
warn: (message) => this.#logger().warn(message)
|
|
507
571
|
});
|
|
@@ -510,6 +574,9 @@ var ClickClackDiscussionService = class {
|
|
|
510
574
|
#reconcileAllPromise;
|
|
511
575
|
#unsubscribeSessionsChanged;
|
|
512
576
|
#closed = false;
|
|
577
|
+
#activation = 0;
|
|
578
|
+
#cleanupPromise;
|
|
579
|
+
#operations = /* @__PURE__ */ new Set();
|
|
513
580
|
constructor(runtime, options = {}) {
|
|
514
581
|
this.#runtime = runtime;
|
|
515
582
|
this.#store = getClickClackDiscussionBindingStore(runtime);
|
|
@@ -517,7 +584,7 @@ var ClickClackDiscussionService = class {
|
|
|
517
584
|
baseUrl: account.apiEndpoint,
|
|
518
585
|
token: account.token
|
|
519
586
|
}));
|
|
520
|
-
this.#installationId = options.installationId
|
|
587
|
+
this.#installationId = options.installationId;
|
|
521
588
|
this.#bindingGenerationFactory = options.bindingGenerationFactory ?? randomUUID;
|
|
522
589
|
this.#detachedBindings = new DetachedDiscussionBindingRetention({
|
|
523
590
|
runtime,
|
|
@@ -530,24 +597,43 @@ var ClickClackDiscussionService = class {
|
|
|
530
597
|
info: async ({ sessionKey }) => await this.info(sessionKey),
|
|
531
598
|
open: async ({ sessionKey }) => await this.open(sessionKey)
|
|
532
599
|
};
|
|
533
|
-
if (options.gatewayEvents) this.bindGatewayEvents(options.gatewayEvents)
|
|
534
|
-
|
|
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
|
+
});
|
|
535
606
|
}
|
|
536
|
-
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;
|
|
537
612
|
this.#unsubscribeSessionsChanged?.();
|
|
538
613
|
this.#closed = false;
|
|
539
614
|
this.#reconcileScheduler.supersede();
|
|
540
615
|
this.#unsubscribeSessionsChanged = gatewayEvents?.onSessionsChanged((event) => {
|
|
541
|
-
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();
|
|
542
630
|
});
|
|
543
|
-
for (const sessionKey of this.#listReconcileSessionKeys()) this.#reconcileScheduler.schedule(sessionKey, 0);
|
|
544
|
-
if (this.#timersEnabled) this.#ensureTimer();
|
|
545
631
|
}
|
|
546
632
|
hasEnabledAccount() {
|
|
547
633
|
return discussionAccounts(this.#currentConfig()).length === 1;
|
|
548
634
|
}
|
|
549
635
|
async info(sessionKey) {
|
|
550
|
-
return await this.#withSessionLock(sessionKey, async () => {
|
|
636
|
+
return await this.#withOperation(() => this.#withSessionLock(sessionKey, async () => {
|
|
551
637
|
if (discussionAccounts(this.#currentConfig()).length !== 1) return { state: "none" };
|
|
552
638
|
const existing = this.#store.get(sessionKey);
|
|
553
639
|
if (existing) {
|
|
@@ -561,103 +647,117 @@ var ClickClackDiscussionService = class {
|
|
|
561
647
|
return { state: "available" };
|
|
562
648
|
}
|
|
563
649
|
if (resolved.state !== "active") return { state: "none" };
|
|
564
|
-
this.#finalizePendingBinding(sessionKey, existing);
|
|
650
|
+
await this.#finalizePendingBinding(sessionKey, existing);
|
|
565
651
|
await this.#reconcileBinding(sessionKey, existing, resolved.account);
|
|
566
652
|
const current = this.#store.get(sessionKey);
|
|
567
653
|
if (!current) return { state: this.hasEnabledAccount() ? "available" : "none" };
|
|
568
654
|
return discussionInfoForBinding(current, resolved.account);
|
|
569
655
|
}
|
|
570
656
|
return { state: "available" };
|
|
571
|
-
});
|
|
657
|
+
}));
|
|
572
658
|
}
|
|
573
659
|
async open(sessionKey) {
|
|
574
|
-
return await this.#withSessionLock(sessionKey,
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
try {
|
|
593
|
-
binding = await openClickClackDiscussionBinding({
|
|
594
|
-
runtime: this.#runtime,
|
|
595
|
-
store: this.#store,
|
|
596
|
-
account,
|
|
597
|
-
clientFactory: this.#clientFactory,
|
|
598
|
-
installationId: this.#installationId,
|
|
599
|
-
bindingGenerationFactory: this.#bindingGenerationFactory,
|
|
600
|
-
sessionKey,
|
|
601
|
-
ensureTimer: () => this.#ensureTimer(),
|
|
602
|
-
reconcilePendingOpen: async (pending) => await this.#reconcilePendingOpen(pending, { allowRetry: false }),
|
|
603
|
-
withChannelMutationLock: async (run) => await this.#withChannelMutationLock(run),
|
|
604
|
-
ensureBindingCapacity: (key) => this.#detachedBindings.ensureCapacity(key),
|
|
605
|
-
finalizePendingBinding: (key, nextBinding) => this.#finalizePendingBinding(key, nextBinding),
|
|
606
|
-
warn: (message) => this.#logger().warn(message)
|
|
607
|
-
});
|
|
608
|
-
} finally {
|
|
609
|
-
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);
|
|
610
678
|
}
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
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);
|
|
614
702
|
}
|
|
615
703
|
async reconcile(sessionKey) {
|
|
704
|
+
return await this.#withOperation(() => this.#reconcile(sessionKey));
|
|
705
|
+
}
|
|
706
|
+
async #reconcile(sessionKey) {
|
|
616
707
|
try {
|
|
617
708
|
await this.#withSessionLock(sessionKey, async () => {
|
|
618
709
|
const binding = this.#store.get(sessionKey);
|
|
619
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);
|
|
620
713
|
});
|
|
621
|
-
const pending = listPendingDiscussionOpens(this.#runtime).find((candidate) => candidate.sessionKey === sessionKey);
|
|
622
|
-
if (pending) await this.#reconcilePendingOpen(pending);
|
|
623
714
|
} finally {
|
|
624
|
-
this.#ensureTimer();
|
|
715
|
+
await this.#ensureTimer();
|
|
625
716
|
}
|
|
626
717
|
}
|
|
627
718
|
async reconcileAll() {
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
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;
|
|
637
735
|
});
|
|
638
|
-
return await this.#reconcileAllPromise;
|
|
639
736
|
}
|
|
640
737
|
async readLatestMessages(sessionKey, limit) {
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
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
|
+
}));
|
|
658
757
|
}
|
|
659
758
|
cleanup() {
|
|
660
759
|
this.#closed = true;
|
|
760
|
+
this.#activation += 1;
|
|
661
761
|
this.#unsubscribeSessionsChanged?.();
|
|
662
762
|
this.#unsubscribeSessionsChanged = void 0;
|
|
663
763
|
this.#reconcileScheduler.supersede();
|
|
@@ -666,9 +766,11 @@ var ClickClackDiscussionService = class {
|
|
|
666
766
|
clearInterval(this.#timer);
|
|
667
767
|
this.#timer = void 0;
|
|
668
768
|
}
|
|
769
|
+
this.#cleanupPromise ??= Promise.allSettled(this.#operations).then(() => void 0);
|
|
770
|
+
return this.#cleanupPromise;
|
|
669
771
|
}
|
|
670
772
|
async #reconcileBinding(sessionKey, binding, resolvedAccount) {
|
|
671
|
-
this.#finalizePendingBinding(sessionKey, binding);
|
|
773
|
+
await this.#finalizePendingBinding(sessionKey, binding);
|
|
672
774
|
if (isClickClackDiscussionChannelRevoked({
|
|
673
775
|
runtime: this.#runtime,
|
|
674
776
|
serverBaseUrl: binding.serverBaseUrl,
|
|
@@ -687,10 +789,7 @@ var ClickClackDiscussionService = class {
|
|
|
687
789
|
}
|
|
688
790
|
const activeBinding = this.#detachedBindings.clear(sessionKey, binding);
|
|
689
791
|
if (!activeBinding) return;
|
|
690
|
-
const resolved = resolvedAccount ?
|
|
691
|
-
state: "active",
|
|
692
|
-
account: resolvedAccount
|
|
693
|
-
} : await this.#resolveBindingForUse(activeBinding);
|
|
792
|
+
const resolved = resolvedAccount ? resolveDiscussionBindingAccount(this.#currentConfig(), activeBinding) : await this.#resolveBindingForUse(activeBinding);
|
|
694
793
|
if (resolved.state === "retargeted") {
|
|
695
794
|
this.#revokeAndDeleteBinding(sessionKey, activeBinding);
|
|
696
795
|
return;
|
|
@@ -771,55 +870,18 @@ var ClickClackDiscussionService = class {
|
|
|
771
870
|
}
|
|
772
871
|
}
|
|
773
872
|
async #reconcilePendingOpen(pending, options = {}) {
|
|
774
|
-
|
|
775
|
-
if (currentBinding?.externalRef === pending.externalRef) {
|
|
776
|
-
this.#finalizePendingBinding(pending.sessionKey, currentBinding);
|
|
777
|
-
return;
|
|
778
|
-
}
|
|
779
|
-
const cfg = this.#currentConfig();
|
|
780
|
-
const account = listClickClackAccountIds(cfg).map((accountId) => resolveClickClackAccount({
|
|
781
|
-
cfg,
|
|
782
|
-
accountId
|
|
783
|
-
})).find((candidate) => candidate.configured && normalizedServerBaseUrl(candidate) === pending.serverBaseUrl && discussionCredentialFingerprint(candidate.token) === pending.credentialFingerprint);
|
|
784
|
-
if (!account) return;
|
|
785
|
-
const client = this.#clientFactory(account);
|
|
786
|
-
const entry = this.#runtime.agent.session.getSessionEntry({
|
|
787
|
-
sessionKey: pending.sessionKey,
|
|
788
|
-
readConsistency: "latest"
|
|
789
|
-
});
|
|
790
|
-
const activeAccounts = discussionAccounts(cfg);
|
|
791
|
-
const retryAccount = activeAccounts.length === 1 ? activeAccounts[0] : void 0;
|
|
792
|
-
if (options.allowRetry !== false && entry?.sessionId && entry.archivedAt === void 0 && retryAccount && normalizedServerBaseUrl(retryAccount) === pending.serverBaseUrl && discussionCredentialFingerprint(retryAccount.token) === pending.credentialFingerprint) {
|
|
793
|
-
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) {
|
|
794
|
-
await this.open(pending.sessionKey);
|
|
795
|
-
return;
|
|
796
|
-
}
|
|
797
|
-
}
|
|
798
|
-
const channels = await client.channels(pending.workspaceId);
|
|
799
|
-
assertManagedChannelListContract(channels);
|
|
800
|
-
const channel = channels.find((candidate) => candidate.external_managed === true && candidate.external_ref === pending.externalRef);
|
|
801
|
-
if (channel) {
|
|
802
|
-
markClickClackDiscussionChannelIdentityRevoked({
|
|
803
|
-
runtime: this.#runtime,
|
|
804
|
-
accountId: pending.accountId,
|
|
805
|
-
serverBaseUrl: pending.serverBaseUrl,
|
|
806
|
-
channelId: channel.id
|
|
807
|
-
});
|
|
808
|
-
clearPendingDiscussionOpen({
|
|
809
|
-
runtime: this.#runtime,
|
|
810
|
-
sessionKey: pending.sessionKey,
|
|
811
|
-
expectedGeneration: pending.generation
|
|
812
|
-
});
|
|
813
|
-
return;
|
|
814
|
-
}
|
|
815
|
-
clearDiscussionBindingGeneration({
|
|
873
|
+
await reconcilePendingDiscussionOpen({
|
|
816
874
|
runtime: this.#runtime,
|
|
817
|
-
|
|
818
|
-
|
|
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)
|
|
819
881
|
});
|
|
820
882
|
}
|
|
821
883
|
async #releaseStaleBinding(sessionKey, binding) {
|
|
822
|
-
clearDiscussionBindingGeneration({
|
|
884
|
+
await clearDiscussionBindingGeneration({
|
|
823
885
|
runtime: this.#runtime,
|
|
824
886
|
sessionKey
|
|
825
887
|
});
|
|
@@ -829,15 +891,15 @@ var ClickClackDiscussionService = class {
|
|
|
829
891
|
markClickClackDiscussionChannelRevoked(this.#runtime, binding);
|
|
830
892
|
this.#store.delete(sessionKey);
|
|
831
893
|
}
|
|
832
|
-
#finalizePendingBinding(sessionKey, binding) {
|
|
833
|
-
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);
|
|
834
896
|
if (pending) {
|
|
835
897
|
clearClickClackDiscussionChannelRevoked({
|
|
836
898
|
runtime: this.#runtime,
|
|
837
899
|
serverBaseUrl: binding.serverBaseUrl,
|
|
838
900
|
channelId: binding.channelId
|
|
839
901
|
});
|
|
840
|
-
clearDiscussionBindingGeneration({
|
|
902
|
+
await clearDiscussionBindingGeneration({
|
|
841
903
|
runtime: this.#runtime,
|
|
842
904
|
sessionKey,
|
|
843
905
|
expectedGeneration: pending.generation
|
|
@@ -847,14 +909,18 @@ var ClickClackDiscussionService = class {
|
|
|
847
909
|
async #resolveBindingForUse(binding) {
|
|
848
910
|
const resolved = resolveDiscussionBindingAccount(this.#currentConfig(), binding);
|
|
849
911
|
if (resolved.state !== "active") return resolved;
|
|
850
|
-
|
|
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" };
|
|
851
916
|
}
|
|
852
917
|
#currentConfig() {
|
|
853
918
|
return this.#runtime.config.current();
|
|
854
919
|
}
|
|
855
|
-
#ensureTimer() {
|
|
856
|
-
|
|
857
|
-
const
|
|
920
|
+
async #ensureTimer() {
|
|
921
|
+
if (this.#closed) return;
|
|
922
|
+
const hasPendingOpens = (await listPendingDiscussionOpens(this.#runtime)).length > 0;
|
|
923
|
+
const needsBindingPoll = this.#unsubscribeSessionsChanged === void 0 && this.#store.count() > 0;
|
|
858
924
|
if (this.#closed || !hasPendingOpens && !needsBindingPoll) {
|
|
859
925
|
if (this.#timer) {
|
|
860
926
|
clearInterval(this.#timer);
|
|
@@ -866,14 +932,12 @@ var ClickClackDiscussionService = class {
|
|
|
866
932
|
this.#timer = setInterval(() => {
|
|
867
933
|
this.reconcileAll().catch((error) => {
|
|
868
934
|
this.#logger().warn(`discussion reconcile pass failed: ${String(error)}`);
|
|
869
|
-
}).finally(() => {
|
|
870
|
-
this.#ensureTimer();
|
|
871
935
|
});
|
|
872
936
|
}, RECONCILE_INTERVAL_MS);
|
|
873
937
|
this.#timer.unref?.();
|
|
874
938
|
}
|
|
875
|
-
#listReconcileSessionKeys() {
|
|
876
|
-
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)]);
|
|
877
941
|
}
|
|
878
942
|
#logger() {
|
|
879
943
|
return this.#runtime.logging.getChildLogger({
|
|
@@ -881,6 +945,13 @@ var ClickClackDiscussionService = class {
|
|
|
881
945
|
feature: "discussions"
|
|
882
946
|
});
|
|
883
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
|
+
}
|
|
884
955
|
async #withSessionLock(sessionKey, run) {
|
|
885
956
|
const current = (this.#sessionLocks.get(sessionKey) ?? Promise.resolve()).catch(() => void 0).then(run);
|
|
886
957
|
this.#sessionLocks.set(sessionKey, current);
|
|
@@ -978,12 +1049,8 @@ function registerClickClackDiscussions(api) {
|
|
|
978
1049
|
const service = new ClickClackDiscussionService(api.runtime);
|
|
979
1050
|
api.registerService({
|
|
980
1051
|
id: "clickclack-discussion-session-events",
|
|
981
|
-
start: ({ gatewayEvents }) =>
|
|
982
|
-
|
|
983
|
-
},
|
|
984
|
-
stop: () => {
|
|
985
|
-
service.cleanup();
|
|
986
|
-
}
|
|
1052
|
+
start: ({ gatewayEvents }) => service.bindGatewayEvents(gatewayEvents),
|
|
1053
|
+
stop: () => service.cleanup()
|
|
987
1054
|
});
|
|
988
1055
|
api.registerTool((context) => createClickClackDiscussionTool({
|
|
989
1056
|
service,
|
|
@@ -1008,7 +1075,7 @@ function registerClickClackDiscussions(api) {
|
|
|
1008
1075
|
description: "Stops the lifecycle reconciler for managed ClickClack discussions.",
|
|
1009
1076
|
cleanup: () => {
|
|
1010
1077
|
unregisterSessionAccess();
|
|
1011
|
-
service.cleanup();
|
|
1078
|
+
return service.cleanup();
|
|
1012
1079
|
}
|
|
1013
1080
|
});
|
|
1014
1081
|
}
|