/**
 * Cassette Types
 *
 * VCR-style cassette format for recording and replaying agent subprocess I/O.
 * A cassette captures everything an agent process writes so tests can replay
 * it deterministically without hitting real AI APIs.
 */

export interface CassetteKey {
  /** Prompt with dynamic content (UUIDs, paths, timestamps) replaced with placeholders. */
  normalizedPrompt: string;
  /** Provider name, e.g. 'claude', 'codex'. */
  providerName: string;
  /** Stable CLI args with the prompt value stripped. */
  modelArgs: string[];
  /** SHA256 prefix of all non-hidden files in the agent worktree at spawn time. */
  worktreeHash: string;
}

export interface CassetteRecording {
  /** All JSONL lines the agent wrote to stdout (captured from output file). */
  jsonlLines: string[];
  /** Content of signal.json written by the agent, or null if missing. */
  signalJson: Record<string, unknown> | null;
  /** Process exit code (0 = success). */
  exitCode: number;
  /** ISO timestamp when this cassette was recorded. */
  recordedAt: string;
  /**
   * All files the agent wrote to .cw/output/ (relative path → UTF-8 content),
   * excluding signal.json (which is captured separately in signalJson).
   * Restored during replay before onComplete fires so downstream readers
   * (e.g. readPhaseFiles, readTaskFiles) see the expected directory contents.
   */
  outputFiles?: Record<string, string>;
}

export interface CassetteEntry {
  version: 1;
  key: CassetteKey;
  recording: CassetteRecording;
}
