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

/**
 * NetaClaw 消息
 */
@Entity('netaclaw_message')
export class NetaClawMessageEntity extends BaseEntity {
  @Index()
  @Column({ comment: '会话ID' })
  sessionId: string;

  @Column({ comment: '角色: system/user/assistant/tool' })
  role: string;

  @Column({ type: 'longtext', comment: '消息内容' })
  content: string;

  @Column({ type: 'longtext', comment: '思考内容', nullable: true })
  thinking: string;

  @Column({ type: 'json', comment: '工具调用', nullable: true })
  toolCalls: unknown;

  @Column({ comment: '工具调用ID', nullable: true })
  toolCallId: string;

  @Column({ comment: 'Skill名称', nullable: true })
  skillName: string;

  @Column({ type: 'json', comment: '元数据', nullable: true })
  metadata: Record<string, unknown>;

  @Column({ comment: '被压缩的时刻', type: 'datetime', nullable: true })
  @Index()
  compactedAt: Date;

  @Column({ comment: '关联的摘要消息ID', nullable: true })
  compactedIntoId: number;

  @Column({ comment: '是否为压缩摘要消息', default: false })
  @Index()
  isCompactionSummary: boolean;
}
