import { BaseEntity } from '../../base/entity/base.js';
import { Column, Entity, Index } from 'typeorm';

@Index(['channelId', 'roomId'], { unique: true })
@Entity('netaclaw_agent_channel_group')
export class NetaClawAgentChannelGroupEntity extends BaseEntity {
  @Column({ comment: '所属频道 ID' })
  channelId: number;

  @Column({ comment: '微信群 roomId，如 12345@chatroom 或 UIA 生成的 ${cid}:room:sha1(name)', length: 255 })
  roomId: string;

  @Column({ comment: '群名称', length: 256, nullable: true })
  roomName: string | null;

  @Index()
  @Column({ comment: '状态 0=禁用(默认) 1=启用 -1=已否决/忽略', default: 0 })
  status: number;

  @Column({ comment: '触发策略 at_mention / all (prefix 保留兼容存量数据)', length: 32, default: 'at_mention' })
  triggerMode: string;

  @Column({ comment: '前缀触发时的前缀 (保留兼容,前端不暴露)', length: 64, nullable: true })
  triggerPrefix: string | null;

  @Column({ comment: '每群绑定的 Agent ID;历史 null 表示未配置', nullable: true })
  boundAgentId: number | null;

  @Column({ comment: '每群回复身份 silent / ai_prefix;历史 null 表示未配置', length: 16, nullable: true })
  replyIdentityOverride: string | null;

  @Column({ comment: '首次被发现时间（ISO 字符串）', length: 32, nullable: true })
  firstSeenAt: string | null;

  @Column({ comment: '最近一次群消息到达时间', length: 32, nullable: true })
  lastSeenAt: string | null;

  @Column({ comment: '最近一次 bot 回复时间', length: 32, nullable: true })
  lastActiveAt: string | null;
}
