MingaEditor.Agent.Transcript (Minga v0.1.0)

Copy Markdown View Source

Pure semantic transcript projection for agent chat.

The visible transcript is carried in Minga.RenderModel.UI.AgentChat.resident_messages and transported by gui_agent_transcript (0x86); gui_agent_chat (0x78) carries only chrome state. This module computes the transcript metadata that commands still need: displayed message windows, stable message ids, line-to-message lookup, code-block line classification, and provenance anchors.

Summary

Types

Line offset: {message_index, start_line, line_count}

Line type for transcript-line-to-message mapping.

Functions

Builds displayed semantic transcript metadata from raw session messages.

Builds a per-line index mapping transcript lines to message indices and line types.

Returns the semantic transcript line where a message starts.

Converts transcript messages to plain markdown text and line offsets.

Resolves the stable message id that should anchor a provenance jump for a tool call.

Types

display_result()

@type display_result() :: %{
  line_index: [{non_neg_integer(), line_type()}],
  display_messages: [term()],
  display_message_pairs: [{pos_integer(), term()}],
  markdown: String.t(),
  line_offsets: [line_offset()]
}

empty_state()

@type empty_state() :: :credentials_missing | :no_model | nil

line_offset()

@type line_offset() :: {non_neg_integer(), non_neg_integer(), non_neg_integer()}

Line offset: {message_index, start_line, line_count}

line_type()

@type line_type() :: :text | :code | :tool | :thinking | :usage | :system | :empty

Line type for transcript-line-to-message mapping.

Functions

display(messages, opts \\ [])

@spec display(
  [term()],
  keyword()
) :: display_result()

Builds displayed semantic transcript metadata from raw session messages.

line_message_index(messages)

@spec line_message_index([term()]) :: [{non_neg_integer(), line_type()}]

Builds a per-line index mapping transcript lines to message indices and line types.

message_start_line(messages, msg_idx)

@spec message_start_line([term()], non_neg_integer()) :: non_neg_integer() | nil

Returns the semantic transcript line where a message starts.

messages_to_markdown_with_offsets(messages)

@spec messages_to_markdown_with_offsets([term()]) :: {String.t(), [line_offset()]}

Converts transcript messages to plain markdown text and line offsets.

turn_anchor_id(messages_with_ids, tool_call_id)

@spec turn_anchor_id([{pos_integer(), term()}], String.t()) :: pos_integer() | nil

Resolves the stable message id that should anchor a provenance jump for a tool call.