Documentation
¶
Overview ¶
Package conversation contains conversation-domain contracts and helpers.
It defines conversation/message/turn mutable types, transcript helpers, and convenience options used by runtime services and SDK layers.
Index ¶
- Variables
- func DecodeInlineBody(inline string, compression string) string
- type Client
- type Conversation
- type GeneratedFile
- type GeneratedFileClient
- type GetRequest
- type GetResponse
- type IndexedMessages
- type Input
- type Message
- type MessageOption
- func WithArchived(v int) MessageOption
- func WithAttachmentPayloadID(id string) MessageOption
- func WithContent(content string) MessageOption
- func WithContextSummary(s string) MessageOption
- func WithConversationID(id string) MessageOption
- func WithCreatedAt(t time.Time) MessageOption
- func WithCreatedByUserID(id string) MessageOption
- func WithElicitationID(id string) MessageOption
- func WithElicitationPayloadID(id string) MessageOption
- func WithId(id string) MessageOption
- func WithInterim(v int) MessageOption
- func WithIteration(v int) MessageOption
- func WithLinkedConversationID(id string) MessageOption
- func WithMode(mode string) MessageOption
- func WithNarration(preamble string) MessageOption
- func WithParentMessageID(id string) MessageOption
- func WithPhase(phase string) MessageOption
- func WithRawContent(content string) MessageOption
- func WithRole(role string) MessageOption
- func WithSequence(v int) MessageOption
- func WithStatus(status string) MessageOption
- func WithSupersededBy(id string) MessageOption
- func WithTags(s string) MessageOption
- func WithToolName(name string) MessageOption
- func WithTurnID(id string) MessageOption
- func WithType(typ string) MessageOption
- func WithUpdatedAt(t time.Time) MessageOption
- type Messages
- type MutableConversation
- type MutableGeneratedFile
- type MutableMessage
- type MutableModelCall
- type MutablePayload
- type MutableToolCall
- type MutableTurn
- type Option
- type Payload
- type ResponsePayloadView
- type Service
- type ToolCallView
- type Transcript
- func (t *Transcript) Filter(f func(v *Message) bool) Messages
- func (t *Transcript) History(minimal bool) []*binding.Message
- func (t Transcript) Last() Transcript
- func (t *Transcript) LastAssistantMessage() *Message
- func (t *Transcript) LastAssistantMessageWithModelCall() *Message
- func (t *Transcript) LastElicitationMessage() *Message
- func (t Transcript) UniqueToolNames() []string
- type Turn
Constants ¶
This section is empty.
Variables ¶
var ErrInvalidInput = errInvalidInput{}
ErrInvalidInput is returned when required inputs are missing.
Functions ¶
func DecodeInlineBody ¶ added in v0.1.8
Types ¶
type Client ¶
type Client interface {
GetConversation(ctx context.Context, id string, options ...Option) (*Conversation, error)
GetConversations(ctx context.Context, input *Input) ([]*Conversation, error)
PatchConversations(ctx context.Context, conversations *MutableConversation) error
GetPayload(ctx context.Context, id string) (*Payload, error)
PatchPayload(ctx context.Context, payload *MutablePayload) error
PatchMessage(ctx context.Context, message *MutableMessage) error
GetMessage(ctx context.Context, id string, options ...Option) (*Message, error)
GetMessageByElicitation(ctx context.Context, conversationID, elicitationID string) (*Message, error)
PatchModelCall(ctx context.Context, modelCall *MutableModelCall) error
PatchToolCall(ctx context.Context, toolCall *MutableToolCall) error
PatchTurn(ctx context.Context, turn *MutableTurn) error
DeleteConversation(ctx context.Context, id string) error
// DeleteMessage removes a message from the conversation and internal indexes.
DeleteMessage(ctx context.Context, conversationID, messageID string) error
}
type Conversation ¶
type Conversation agconv.ConversationView
func (*Conversation) GetTranscript ¶
func (c *Conversation) GetTranscript() Transcript
func (*Conversation) HasConversationParent ¶
func (c *Conversation) HasConversationParent() bool
type GeneratedFile ¶
type GeneratedFile = gfread.GeneratedFileView
type GeneratedFileClient ¶
type GeneratedFileClient interface {
GetGeneratedFiles(ctx context.Context, input *gfread.Input) ([]*gfread.GeneratedFileView, error)
PatchGeneratedFile(ctx context.Context, generatedFile *gfwrite.GeneratedFile) error
}
GeneratedFileClient is an optional extension implemented by concrete conversation clients that support generated-file persistence.
type GetRequest ¶
type GetRequest struct {
Id string
Since string
IncludeTranscript bool
IncludeModelCall bool
IncludeToolCall bool
}
GetRequest defines parameters to retrieve a conversation view.
type GetResponse ¶
type GetResponse struct {
Conversation *Conversation
}
GetResponse wraps the conversation view.
type IndexedMessages ¶
func (IndexedMessages) BuildMatchIndex ¶
BuildMatchIndex returns a set of tool-call opIds that should be included for a continuation anchored at anchorID/anchorTime.
type Input ¶
type Input = agconv.ConversationInput
type Message ¶
type Message agconv.MessageView
func (*Message) GetContent ¶
GetContent returns the printable content for this message. - For tool-call messages, it prefers the response payload inline body. - For user/assistant messages, it returns the message content field.
func (*Message) GetContentPreferContent ¶
func (*Message) IsArchived ¶
func (*Message) NewMutable ¶
func (m *Message) NewMutable() *MutableMessage
func (*Message) ToolCallArguments ¶
ToolCallArguments returns parsed arguments for a tool-call message. It prefers the request payload inline JSON body when present. When parsing fails or no payload is present, it returns an empty map.
type MessageOption ¶
type MessageOption func(m *MutableMessage)
MessageOption configures a MutableMessage prior to persistence.
func WithArchived ¶
func WithArchived(v int) MessageOption
func WithAttachmentPayloadID ¶
func WithAttachmentPayloadID(id string) MessageOption
func WithContent ¶
func WithContent(content string) MessageOption
func WithContextSummary ¶
func WithContextSummary(s string) MessageOption
Optional summaries/tags (set via raw fields when no setter exists)
func WithConversationID ¶
func WithConversationID(id string) MessageOption
func WithCreatedByUserID ¶
func WithCreatedByUserID(id string) MessageOption
func WithElicitationID ¶
func WithElicitationID(id string) MessageOption
func WithElicitationPayloadID ¶
func WithElicitationPayloadID(id string) MessageOption
func WithInterim ¶
func WithInterim(v int) MessageOption
func WithIteration ¶
func WithIteration(v int) MessageOption
func WithLinkedConversationID ¶
func WithLinkedConversationID(id string) MessageOption
func WithMode ¶
func WithMode(mode string) MessageOption
func WithNarration ¶ added in v0.1.8
func WithNarration(preamble string) MessageOption
func WithParentMessageID ¶
func WithParentMessageID(id string) MessageOption
func WithPhase ¶ added in v0.1.8
func WithPhase(phase string) MessageOption
func WithRawContent ¶
func WithRawContent(content string) MessageOption
func WithSequence ¶
func WithSequence(v int) MessageOption
func WithStatus ¶
func WithStatus(status string) MessageOption
func WithSupersededBy ¶
func WithSupersededBy(id string) MessageOption
func WithTags ¶
func WithTags(s string) MessageOption
func WithToolName ¶
func WithToolName(name string) MessageOption
func WithTurnID ¶
func WithTurnID(id string) MessageOption
func WithType ¶
func WithType(typ string) MessageOption
func WithUpdatedAt ¶
func WithUpdatedAt(t time.Time) MessageOption
type Messages ¶
type Messages []*Message
func (Messages) LatestByCreatedAt ¶
LatestByCreatedAt returns the last non-nil message by CreatedAt timestamp. When messages are empty or all nil, it returns nil.
func (Messages) SortByCreatedAt ¶
SortByCreatedAt sorts the messages in-place by CreatedAt. When asc is true, earlier messages come first; otherwise latest first.
func (Messages) SortedByCreatedAt ¶
SortedByCreatedAt returns a new slice with messages ordered by CreatedAt. When asc is true, earlier messages come first; otherwise latest first.
type MutableConversation ¶
type MutableConversation = convw.Conversation
func NewConversation ¶
func NewConversation() *MutableConversation
NewConversation allocates a mutable conversation with Has populated.
type MutableGeneratedFile ¶
type MutableGeneratedFile = gfwrite.GeneratedFile
func NewGeneratedFile ¶
func NewGeneratedFile() *MutableGeneratedFile
NewGeneratedFile allocates a mutable generated file with Has populated.
type MutableMessage ¶
func AddMessage ¶
func AddMessage(ctx context.Context, cl Client, turn *runtimerequestctx.TurnMeta, opts ...MessageOption) (*MutableMessage, error)
AddMessage creates and persists a message attached to the given turn using the provided options. It sets sensible defaults: id (uuid), conversation/turn/parent ids from turn, and type "text" unless overridden. Returns the message id.
func NewMessage ¶
func NewMessage() *MutableMessage
NewMessage allocates a mutable message with Has populated.
type MutableModelCall ¶
func NewModelCall ¶
func NewModelCall() *MutableModelCall
NewModelCall allocates a mutable model call with Has populated.
type MutablePayload ¶
func NewPayload ¶
func NewPayload() *MutablePayload
NewPayload allocates a mutable payload with Has populated.
type MutableToolCall ¶
func NewToolCall ¶
func NewToolCall() *MutableToolCall
NewToolCall allocates a mutable tool call with Has populated.
type MutableTurn ¶
type Option ¶
type Option func(input *Input)
func WithIncludeModelCall ¶
func WithIncludeToolCall ¶
func WithIncludeTranscript ¶
func WithToolFeedSpec ¶
WithToolFeedSpec populates the transient FeedSpec list on the input so that OnRelation hooks can compute tool executions based on metadata.
type Payload ¶
type Payload = payloadread.PayloadView
type ResponsePayloadView ¶
type ResponsePayloadView = agconv.ModelCallStreamPayloadView
type Service ¶
type Service struct {
// contains filtered or unexported fields
}
Service is a thin wrapper around API to support request/response types.
func NewService ¶
func (*Service) Get ¶
func (s *Service) Get(ctx context.Context, req GetRequest) (*GetResponse, error)
Get fetches a conversation based on the request fields.
type ToolCallView ¶
type ToolCallView = agconv.ToolCallView
type Transcript ¶
type Transcript []*Turn
func (Transcript) Last ¶
func (t Transcript) Last() Transcript
func (*Transcript) LastAssistantMessage ¶
func (t *Transcript) LastAssistantMessage() *Message
LastAssistantMessage returns the last assistant text message in this transcript. It scans turns from the end and messages from the end to preserve chronology.
func (*Transcript) LastAssistantMessageWithModelCall ¶
func (t *Transcript) LastAssistantMessageWithModelCall() *Message
LastAssistantMessageWithModelCall returns the last assistant text message in this transcript that has a model call. It scans turns from the end and messages from the end to preserve chronology.
func (*Transcript) LastElicitationMessage ¶
func (t *Transcript) LastElicitationMessage() *Message
func (Transcript) UniqueToolNames ¶
func (t Transcript) UniqueToolNames() []string
UniqueToolNames returns a de-duplicated list of tool names (service/method) observed across all messages in the transcript, preserving encounter order.