clawgram 2.22.0 → 2.24.0

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/helpers.js CHANGED
@@ -46,6 +46,9 @@ exports.normalizeParseMode = normalizeParseMode;
46
46
  exports.resolveReplyParseMode = resolveReplyParseMode;
47
47
  exports.resolveOutboundParseMode = resolveOutboundParseMode;
48
48
  exports.resolveDryRun = resolveDryRun;
49
+ exports.parseOptionalThreadId = parseOptionalThreadId;
50
+ exports.readAccountReactionLevel = readAccountReactionLevel;
51
+ exports.readAccountReactionModel = readAccountReactionModel;
49
52
  const node_fs_1 = require("node:fs");
50
53
  const node_path_1 = __importDefault(require("node:path"));
51
54
  const core_1 = require("openclaw/plugin-sdk/core");
@@ -883,3 +886,47 @@ function resolveOutboundParseMode(params, cfg, accountId) {
883
886
  ? resolveReplyParseMode(cfg, accountId)
884
887
  : normalizeParseMode(raw);
885
888
  }
889
+ /**
890
+ * `messageThreadId` из параметров: число, строка из цифр — или ничего.
891
+ *
892
+ * Живёт здесь, а не в channel.ts: им пользуется и диспетчер, и исходящий
893
+ * контур, а импорт из channel.ts в outbound.ts замкнул бы круг.
894
+ */
895
+ function parseOptionalThreadId(value) {
896
+ if (typeof value === "number") {
897
+ return Number.isFinite(value) ? Math.trunc(value) : undefined;
898
+ }
899
+ if (typeof value !== "string") {
900
+ return undefined;
901
+ }
902
+ const trimmed = value.trim();
903
+ if (!trimmed || !/^\d+$/.test(trimmed)) {
904
+ return undefined;
905
+ }
906
+ const parsed = Number.parseInt(trimmed, 10);
907
+ return Number.isFinite(parsed) ? parsed : undefined;
908
+ }
909
+ /** Reads the configured reaction level for an account, tolerating a missing config. */
910
+ function readAccountReactionLevel(cfg, accountId) {
911
+ const resolvedAccountId = resolveConfiguredAccountId(cfg, accountId);
912
+ if (!resolvedAccountId) {
913
+ return undefined;
914
+ }
915
+ return cfg?.channels?.[constants_1.CHANNEL_ID]?.accounts?.[resolvedAccountId]?.reactionLevel;
916
+ }
917
+ /**
918
+ * Model ref for the emoji pick, when the account names one.
919
+ *
920
+ * Picking one emoji out of a fixed list of 68 is the cheapest judgement this
921
+ * channel makes and the only model call it makes on its own; running it on the
922
+ * agent's own head spends the expensive quota on a decision a small model
923
+ * makes just as well.
924
+ */
925
+ function readAccountReactionModel(cfg, accountId) {
926
+ const resolvedAccountId = resolveConfiguredAccountId(cfg, accountId);
927
+ if (!resolvedAccountId) {
928
+ return undefined;
929
+ }
930
+ const raw = cfg?.channels?.[constants_1.CHANNEL_ID]?.accounts?.[resolvedAccountId]?.reactionModel;
931
+ return typeof raw === "string" && raw.trim() ? raw.trim() : undefined;
932
+ }