import { Context, Session } from "koishi"; import { Config } from "../config"; export interface MessageContext { chatId: string; content: string; isMentioned: boolean; isQuote: boolean; isDirect: boolean; } /** * 决策结果 */ export interface ReplyDecision { decision: boolean; probability: number; reason: "probability_roll" | "refractory_period" | "forced_reply_by_mention" | "below_threshold"; } export declare class WillingnessManager { private readonly ctx; private readonly baseConfig; private logger; private willingnessScores; private lastMessageTimestamps; private sessions; private decayInterval; constructor(ctx: Context, config: Config); /** * 获取并缓存解析后的配置 */ private _getResolvedConfig; startDecayCycle(): void; stopDecayCycle(): void; private _decay; /** * 核心计算方法: 根据上下文计算意愿增益 * 增益计算逻辑: "边际递减" * @param context 消息上下文 * @returns 本次消息产生的意愿增益值 */ private calculateGain; /** * 公开接口:更新意愿值并返回回复概率 * @param context 消息上下文 * @returns 回复概率 (0-1) */ calculateReplyProbability(session: Session, context: MessageContext): number; /** * 回复前处理:扣除发言成本 * @param chatId 聊天ID */ handlePreReply(chatId: string): void; /** * 在成功回复后执行。重置或降低意愿,进入"冷却期"。 * @param chatId 聊天ID * @param replyContent 回复内容的长度,可以用来决定惩罚力度 */ handlePostReply(session: Session, chatId: string, replyContentLength?: number): void; /** * 获取指定聊天的当前意愿值(用于调试和监控)。 * @param chatId 聊天ID */ getCurrentWillingness(chatId: string): number; /** * 核心决策方法:判断是否应该回复。 * @param session 消息上下文 * @returns 一个包含决策结果和概率的对象 */ shouldReply(session: Session): { decision: boolean; probability: number; }; /** * 引导模型关注被跳过的话题(用于策略3) */ boostSkippedTopic(session: Session, chatId: string): void; }