ChatContext
Create a ChatContext, optionally seeded with messages. Also exposesChatContext.empty(), ChatContext.fromContextMessages(...), and ChatContext.fromDict(...).
Constructor
addAttributedMessage
agentId.
addFunctionCall
addFunctionOutput
callId.
addHandoff
addMessage
messageId if none is given.
With replace=true and role=SYSTEM, replaces the existing system message in
place instead of appending a duplicate.
copy
estimatedTokens
handoffs
lastHandoff
null if none.
merge
messageId; returns this context.
messages
toAnthropicMessages
system
(Anthropic takes it as a top-level field, not as a message).
toContextMessages
toDict
toGoogleContents
contents, with the system text returned in systemInstruction.
toOpenaiMessages
truncate
turnCount
ChatMessage
Create a ChatMessage.Constructor
Author role. Defaults to ChatRole.USER.
Message text. Defaults to
''.Stable message id. Defaults to
''.Tool calls requested in this message. Defaults to
[].Id of the tool call this message responds to. Defaults to
''.Attached images. Defaults to
[].Id of the agent that authored the message (multi-agent attribution). Defaults to
''.Creation timestamp (epoch seconds), or
null when unset. Defaults to null.ChatContent
Create a ChatContent text block.Constructor
Content kind. Defaults to
'text'.The text body. Defaults to
''.ChatRole
Author role of a ChatMessage.FunctionCall
Create a FunctionCall.Constructor
Name of the tool being called. Defaults to
''.Call arguments as a JSON string. Defaults to
''.Unique id correlating this call with its output. Defaults to
''.FunctionCallOutput
Create a FunctionCallOutput.Constructor
Name of the tool that produced this output. Defaults to
''.The tool’s result, serialized as a string. Defaults to
''.Id matching the originating FunctionCall. Defaults to
''.Whether the output represents an error. Defaults to
false.ImageContent
Create an ImageContent, or one of its helper constructors:fromUrl, fromDataUrl, fromBase64, fromBytes, fromFile, fromFrame.
All accept a detail hint ('auto' | 'low' | 'high', default 'auto').
Constructor
Content kind. Defaults to
'image'.Image URL or
data: URL. Defaults to ''.Vision detail hint:
'auto', 'low', or 'high'. Defaults to 'auto'.ContextWindow
Configure how conversation history is bounded and trimmed. See ContextWindowOptions.Constructor
Maximum tokens of conversation history to keep. Defaults to
null (no token limit).Maximum number of history items (messages/turns) to keep. Defaults to
null (no item limit).Number of most recent turns always preserved verbatim when trimming. Defaults to
3.Maximum tool calls allowed within a single turn. Defaults to
10.Optional LLM used to summarize older history when trimming. Defaults to
null (no summarization).EncodeOptions
Create an EncodeOptions. Pass{ resizeOptions: null } to preserve the
source dimensions; omitting it resizes to 1024x1024.
Constructor
Output format. Default:
'JPEG'.Target dimensions, or
null to keep the source size. Default: 1024x1024.JPEG quality, 0-100 (ignored for PNG). Default:
75.ResizeOptions
Create a ResizeOptions from width and height in pixels.Constructor
encode
sharp dependency. Uses EncodeOptions defaults when options
is omitted or null.
coerceImageToJpegBytes
frame is already encoded bytes (Buffer/Uint8Array/ArrayBuffer), it is
returned as-is (assumed to be a valid JPEG/PNG) and sharp is not required. Otherwise
the frame is encoded with options (or DEFAULT_REALTIME_ENCODE_OPTIONS).