/**
 * API-level transcript summary types (on-disk format is pi-coding-agent JSONL + `sessions.json`).
 */

import type { TranscriptStoredRow } from './session-context-for-llm.js';

export const XOPC_SESSION_TRANSCRIPT_TYPE = 'xopc_session_transcript' as const;

export const CURRENT_SESSION_TRANSCRIPT_VERSION = 1;

/** Record appended when context compaction runs (mirrors pi `CompactionEntry` audit fields). */
export interface TranscriptCompactionRecord {
  at: string;
  summary: string;
  firstKeptIndex: number;
  tokensBefore: number;
  tokensAfter: number;
}

/** Synthetic document shape returned by {@link SessionStore.loadTranscriptDocument} for API parity. */
export interface XopcSessionTranscriptV1 {
  type: typeof XOPC_SESSION_TRANSCRIPT_TYPE;
  version: number;
  id: string;
  createdAt: string;
  updatedAt: string;
  messages: TranscriptStoredRow[];
  compactions?: TranscriptCompactionRecord[];
}
