Documentation
¶
Overview ¶
Package msg holds the conversation's types. It is pure: workflow code imports it, so it does no I/O and reads no clock (AGENTS.md, invariant 1).
Index ¶
Constants ¶
const ( Text = "text" ToolUse = "tool_use" ToolResult = "tool_result" Image = "image" )
Part kinds.
const ( MaxImages = 8 // MaxImageBytes is an image's bytes at most: the API's 5 MB is of its // base64. MaxImageBytes = 5 << 20 / 4 * 3 // MaxRequestImageBytes is the images' bytes at most in a message, and // in what one model call is given (base64 20 MB, the request 32 MB at // most): older images past it are not sent again. MaxRequestImageBytes = 20 << 20 / 4 * 3 // MaxRequestImages is how many images one model call is given at most. MaxRequestImages = 50 )
Variables ¶
var ImageTypes = []string{"image/png", "image/jpeg", "image/gif", "image/webp"}
Images: the kinds a message may carry, and how many and how large (ADR 0026, after the Claude API's limits).
Functions ¶
This section is empty.
Types ¶
type Message ¶
type Message struct {
Role Role `json:"role"`
Parts []Part `json:"parts"`
// Native is the provider's own encoding of an assistant message, sent back
// unchanged to that provider: it carries what the neutral parts do not,
// such as thinking blocks and their signatures.
Native *Native `json:"native,omitempty"`
}
Message is one message of a conversation. It is stored once, by the hash of its content (design 2.2), and never changed.
type Native ¶
type Native struct {
Provider string `json:"provider"`
Raw json.RawMessage `json:"raw"`
}
type Part ¶
type Part struct {
Type string `json:"type"`
Text string `json:"text,omitempty"`
// ID, Name and Input describe a tool_use.
ID string `json:"id,omitempty"`
Name string `json:"name,omitempty"`
Input json.RawMessage `json:"input,omitempty"`
// ToolUseID and IsError describe a tool_result (its content is Text).
ToolUseID string `json:"tool_use_id,omitempty"`
IsError bool `json:"is_error,omitempty"`
// MediaType and Ref describe an image (ADR 0026): its bytes are stored
// once, apart, by their hash (Ref). Data is those bytes, filled in for a
// provider and never stored.
MediaType string `json:"media_type,omitempty"`
Ref string `json:"ref,omitempty"`
Data []byte `json:"-"`
}
Part is one piece of a message, in the provider-neutral shape KairoCode reasons about.