@threadplane/ag-uiFunctionv0.3.7

projectMessages

Display only: projects the session's root transcript into core messages, so views written for core snapshots (message rows, the reasoning disclosure) can render an AG-UI conversation. Request history stays owned by the session.

  • User and assistant text become messages. An assistant record lists the calls projectToolCalls shows for it as toolCallIds, and is a message even without text once it has one. A tool record becomes a tool message with its text and toolCallId.
  • A system record with text becomes a system message, as the Angular adapter showed one a messages snapshot carried. A developer record does too, the core contract having no such role, marked extra['ag-ui'].role: 'developer'. Activity records and child-attributed records are not messages: a subagent activity is a child agent, and every record stays in transcript.
  • A user or tool record whose content is a list of parts also carries blocks: a text block for each text part and an image block for each image part with a URL source. content stays the text. Any other part (audio, video, a document, inline image data) is kept verbatim under extra['ag-ui'].parts.
  • The protocol sends reasoning as its own records. Each is attached to the next assistant record as that message's reasoning; several before one assistant are joined by blank lines. Reasoning with no assistant record after it yet is shown as an assistant message under the reasoning record's identifier, so the row's identifier changes once the answer record arrives.
  • An assistant message carries the sources the application state lists for it under state.citations[messageId], as core citations.
  • reasoningDurationMs is the sum of the times the session measured for the attached reasoning records, and absent when it measured none.
  • While the session runs, the message built from the transcript's last root record is streaming. Every other message is complete: with the run's outcome for the last assistant message of the latest turn, otherwise with success.

previous is an optional identity hint: unchanged messages, and an unchanged list, are returned as the same references. Selection is O(N).

import { projectMessages } from '@threadplane/ag-ui';

Declaration · overload 1

export declare function projectMessages(snapshot: Projectable, previous?: readonly Message[]): readonly Message[];

Parameters

snapshot · required
Projectable
previous · optional
readonly Message[]

Returns

readonly Message[]