import { Injectable } from "@nestjs/common"; import type { EmotionTag } from "@kokorone/shared"; import { ScheduleService } from "./schedule.service.js"; export interface BaselineSignal { tag: EmotionTag; intensity: number; } const CLUB_TIRED_WINDOW_MINUTES = 30; // I-5 作息驅動情緒基線:社團剛結束的疲憊、假日心情基線偏高等日內波動。 // 只在本輪對話「沒有明確情緒訊號」時介入,不覆蓋使用者輸入本身觸發的情緒。 @Injectable() export class ScheduleEmotionBaselineService { constructor(private readonly schedule: ScheduleService) {} async computeBaseline(characterId: string, now: Date = new Date()): Promise { const justEnded = await this.schedule.slotJustEnded(characterId, now, CLUB_TIRED_WINDOW_MINUTES); if (justEnded?.label?.includes("社團")) { return { tag: "SAD", intensity: 0.3 }; // 累 } const dayType = await this.schedule.getDayType(characterId, now); if (dayType === "HOLIDAY" || dayType === "WEEKEND") { return { tag: "JOY", intensity: 0.3 }; // 放假日心情基線偏高 } return null; } }