/**
 * Role of a request segment. Drives the segment's color in the anatomy bar.
 *
 * - `system`: the system prompt (Anthropic `system`, or leading system-role message in OpenAI)
 * - `user`: a user-role message
 * - `assistant`: an assistant-role message
 * - `tool`: a tool-role message (OpenAI only — Anthropic uses tool_result blocks inside user messages)
 * - `tools`: the synthetic "tool definitions" segment that aggregates the `tools` array
 */
export type AnatomyRole = "system" | "user" | "assistant" | "tool" | "tools";

/**
 * A single segment of a request as visualized in the Anatomy tab.
 *
 * `path` is a JSON-pointer-style path into the parsed body
 * (e.g. `/system`, `/messages/0`, `/tools`). The path is opaque to
 * consumers — it is matched against the same path emitted by the
 * request analyzer, and is used to drive click-to-jump in the
 * `JsonViewer`. A `null` path is allowed for the synthetic `tools`
 * segment in the rare case where the tools array cannot be located.
 */
export type AnatomySegment = {
  /** Stable role used for color and label prefix. */
  role: AnatomyRole;
  /** Human-readable short label shown below the segment (e.g. "system", "[3] user", "tools"). */
  label: string;
  /** Estimated token count for this segment. Drives bar width. */
  size: number;
  /** Character count for this segment (raw text length). Used in the tooltip. */
  characters: number;
  /** Raw text of the segment used to compute `size`. Used in the tooltip preview. */
  text: string;
  /**
   * JSON-pointer-style path into the parsed body (e.g. `/messages/3`).
   * `null` when the segment does not correspond to a single node
   * (e.g. the synthetic `tools` segment that aggregates the array).
   */
  path: string;
};
