Skip to content

Message

Defined in: src/types/messages.ts:70

A message in a conversation between user and assistant. Each message has a role (user or assistant) and an array of content blocks.

new Message(data): Message;

Defined in: src/types/messages.ts:101

ParameterType
data{ role: Role; content: ContentBlock[]; trackingId?: string; metadata?: MessageMetadata; }
data.roleRole
data.contentContentBlock[]
data.trackingId?string
data.metadata?MessageMetadata

Message

readonly type: "message";

Defined in: src/types/messages.ts:74

Discriminator for message type.


readonly role: Role;

Defined in: src/types/messages.ts:79

The role of the message sender.


readonly content: ContentBlock[];

Defined in: src/types/messages.ts:84

Array of content blocks that make up this message.


readonly trackingId: string;

Defined in: src/types/messages.ts:94

Durable, stable UUID for the message, assigned at construction. Every Message has one — a caller-supplied id is preserved, otherwise a fresh UUID is minted (so callers do not normally set it; a caller supplying its own should use a UUID v4, e.g. crypto.randomUUID()). Survives session save/restore, and is stripped before model calls. Preserved when a message is copied or restored, so ids are unique within a conversation, but the same message carries the same id across sessions (copying another agent’s messages does not re-key them).


optional metadata?: MessageMetadata;

Defined in: src/types/messages.ts:99

Optional metadata, not sent to model providers.

static fromMessageData(data): Message;

Defined in: src/types/messages.ts:115

Creates a Message instance from MessageData.

ParameterType
dataMessageData

Message


toJSON(): MessageData;

Defined in: src/types/messages.ts:131

Serializes the Message to a JSON-compatible MessageData object. Called automatically by JSON.stringify().

MessageData

JSONSerializable.toJSON

static fromJSON(data): Message;

Defined in: src/types/messages.ts:147

Creates a Message instance from MessageData. Alias for fromMessageData for API consistency.

ParameterTypeDescription
dataMessageDataMessageData to deserialize

Message

Message instance


clone(): Message;

Defined in: src/types/messages.ts:154

Creates a deep copy of this Message (round-trips through serialization).

Message