Message
Defined in: src/types/messages.ts:33
A message in a conversation between user and assistant. Each message has a role (user or assistant) and an array of content blocks.
Implements
Section titled “Implements”JSONSerializable<MessageData>
Constructors
Section titled “Constructors”Constructor
Section titled “Constructor”new Message(data): Message;Defined in: src/types/messages.ts:49
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
data | { role: Role; content: ContentBlock[]; } |
data.role | Role |
data.content | ContentBlock[] |
Returns
Section titled “Returns”Message
Properties
Section titled “Properties”readonly type: "message";Defined in: src/types/messages.ts:37
Discriminator for message type.
readonly role: Role;Defined in: src/types/messages.ts:42
The role of the message sender.
content
Section titled “content”readonly content: ContentBlock[];Defined in: src/types/messages.ts:47
Array of content blocks that make up this message.
Methods
Section titled “Methods”fromMessageData()
Section titled “fromMessageData()”static fromMessageData(data): Message;Defined in: src/types/messages.ts:57
Creates a Message instance from MessageData.
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
data | MessageData |
Returns
Section titled “Returns”Message
toJSON()
Section titled “toJSON()”toJSON(): MessageData;Defined in: src/types/messages.ts:70
Serializes the Message to a JSON-compatible MessageData object. Called automatically by JSON.stringify().
Returns
Section titled “Returns”Implementation of
Section titled “Implementation of”JSONSerializable.toJSONfromJSON()
Section titled “fromJSON()”static fromJSON(data): Message;Defined in: src/types/messages.ts:84
Creates a Message instance from MessageData. Alias for fromMessageData for API consistency.
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
data | MessageData | MessageData to deserialize |
Returns
Section titled “Returns”Message
Message instance