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

@Entity('netaclaw_agent_channel')
export class NetaClawAgentChannelEntity extends BaseEntity {
  @Index({ unique: true })
  @Column({ comment: '频道名称', length: 100 })
  name: string;

  @Index()
  @Column({ comment: '频道类型', length: 50, default: 'weixin' })
  type: string;

  @Index()
  @Column({ comment: '绑定 Agent ID', nullable: true })
  agentId: number | null;

  @Column({ comment: '绑定 Agent 名称', nullable: true, length: 100 })
  agentName: string | null;

  @Column({ comment: '说明', type: 'text', nullable: true })
  description: string;

  @Column({ comment: '频道配置', type: 'json', nullable: true })
  config: Record<string, any>;

  @Column({ comment: '认证信息', type: 'json', nullable: true })
  credential: Record<string, any> | null;

  @Column({ comment: '运行态信息', type: 'json', nullable: true })
  runtime: Record<string, any>;

  @Column({ comment: '登录状态 pending/disconnected/connected/error', length: 30, default: 'disconnected' })
  loginStatus: string;

  @Column({ comment: '最后错误', type: 'text', nullable: true })
  lastError: string | null;

  @Column({ comment: '最近连接时间', nullable: true, length: 32 })
  lastConnectedAt: string | null;

  @Index()
  @Column({ comment: '状态 0=禁用 1=启用', default: 1 })
  status: number;
}
