refactor(reactions): share reaction level resolver

This commit is contained in:
Peter Steinberger
2026-02-14 13:35:21 +00:00
parent b769b65b48
commit 81361755b7
4 changed files with 151 additions and 97 deletions

View File

@@ -1,17 +1,13 @@
import type { OpenClawConfig } from "../config/config.js";
import {
resolveReactionLevel,
type ReactionLevel,
type ResolvedReactionLevel as BaseResolvedReactionLevel,
} from "../utils/reaction-level.js";
import { resolveTelegramAccount } from "./accounts.js";
export type TelegramReactionLevel = "off" | "ack" | "minimal" | "extensive";
export type ResolvedReactionLevel = {
level: TelegramReactionLevel;
/** Whether ACK reactions (e.g., 👀 when processing) are enabled. */
ackEnabled: boolean;
/** Whether agent-controlled reactions are enabled. */
agentReactionsEnabled: boolean;
/** Guidance level for agent reactions (minimal = sparse, extensive = liberal). */
agentReactionGuidance?: "minimal" | "extensive";
};
export type TelegramReactionLevel = ReactionLevel;
export type ResolvedReactionLevel = BaseResolvedReactionLevel;
/**
* Resolve the effective reaction level and its implications.
@@ -24,41 +20,9 @@ export function resolveTelegramReactionLevel(params: {
cfg: params.cfg,
accountId: params.accountId,
});
const level = (account.config.reactionLevel ?? "minimal") as TelegramReactionLevel;
switch (level) {
case "off":
return {
level,
ackEnabled: false,
agentReactionsEnabled: false,
};
case "ack":
return {
level,
ackEnabled: true,
agentReactionsEnabled: false,
};
case "minimal":
return {
level,
ackEnabled: false,
agentReactionsEnabled: true,
agentReactionGuidance: "minimal",
};
case "extensive":
return {
level,
ackEnabled: false,
agentReactionsEnabled: true,
agentReactionGuidance: "extensive",
};
default:
// Fallback to ack behavior
return {
level: "ack",
ackEnabled: true,
agentReactionsEnabled: false,
};
}
return resolveReactionLevel({
value: account.config.reactionLevel,
defaultLevel: "minimal",
invalidFallback: "ack",
});
}