mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-09 12:07:40 +00:00
refactor(reactions): share reaction level resolver
This commit is contained in:
@@ -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",
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user