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

/**
 * Session tree session storage for MySQL provider.
 */
@Index(['sessionId'], { unique: true })
@Entity('netaclaw_agent_session')
export class NetaClawAgentSessionEntity extends BaseEntity {
  @Column({ comment: 'Session tree session id' })
  sessionId: string;

  @Column({ comment: 'Provider name', length: 100 })
  provider: string;

  @Column({ comment: 'Pi root entry id, not the BaseEntity primary key', length: 255, nullable: true })
  rootEntryId: string | null;

  @Column({ comment: 'Pi leaf entry id, not the BaseEntity primary key', length: 255, nullable: true })
  leafEntryId: string | null;

  @Column({ comment: 'Working directory', type: 'text', nullable: true })
  cwd: string | null;

  @Column({ comment: 'Session file path', type: 'text', nullable: true })
  sessionFile: string | null;

  @Column({ comment: 'Parent session id', length: 255, nullable: true })
  parentSessionId: string | null;

  @Column({ comment: 'Agent id', length: 255, nullable: true })
  agentId: string | null;

  @Column({ comment: 'User id', length: 255, nullable: true })
  userId: string | null;

  @Column({ comment: 'Session title', length: 255, nullable: true })
  title: string | null;

  @Column({ comment: 'Session status', length: 50, nullable: true })
  status: string | null;

  @Column({ type: 'json', comment: 'Session metadata', nullable: true })
  metadata: Record<string, unknown> | null;
}
