conversation

package
v0.2.49 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 13, 2026 License: Apache-2.0 Imports: 20 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrInvalidInput = errInvalidInput{}

ErrInvalidInput is returned when required inputs are missing.

Functions

This section is empty.

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 added in v0.2.2

func (c *Conversation) HasConversationParent() bool

type GetRequest

type GetRequest struct {
	Id               string
	Since            string
	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 added in v0.2.18

type IndexedMessages map[string]*Message

func (IndexedMessages) BuildMatchIndex added in v0.2.18

func (n IndexedMessages) BuildMatchIndex(anchorID string, anchorTime time.Time) map[string]bool

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 added in v0.2.6

func (m *Message) GetContent() string

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 added in v0.2.28

func (m *Message) GetContentPreferContent() string

func (*Message) IsArchived added in v0.2.1

func (m *Message) IsArchived() bool

func (*Message) IsInterim

func (m *Message) IsInterim() bool

func (*Message) NewMutable added in v0.2.2

func (m *Message) NewMutable() *MutableMessage

func (*Message) ToolCallArguments added in v0.2.6

func (m *Message) ToolCallArguments() map[string]interface{}

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 added in v0.2.2

type MessageOption func(m *MutableMessage)

MessageOption configures a MutableMessage prior to persistence.

func WithArchived added in v0.2.2

func WithArchived(v int) MessageOption

func WithAttachmentPayloadID added in v0.2.2

func WithAttachmentPayloadID(id string) MessageOption

func WithContent added in v0.2.2

func WithContent(content string) MessageOption

func WithContextSummary added in v0.2.2

func WithContextSummary(s string) MessageOption

Optional summaries/tags (set via raw fields when no setter exists)

func WithConversationID added in v0.2.2

func WithConversationID(id string) MessageOption

func WithCreatedAt added in v0.2.2

func WithCreatedAt(t time.Time) MessageOption

Metadata and attribution

func WithCreatedByUserID added in v0.2.2

func WithCreatedByUserID(id string) MessageOption

func WithElicitationID added in v0.2.2

func WithElicitationID(id string) MessageOption

func WithElicitationPayloadID added in v0.2.2

func WithElicitationPayloadID(id string) MessageOption

func WithId added in v0.2.2

func WithId(id string) MessageOption

Core identifiers and linkage

func WithInterim added in v0.2.2

func WithInterim(v int) MessageOption

func WithLinkedConversationID added in v0.2.2

func WithLinkedConversationID(id string) MessageOption

func WithMode added in v0.2.2

func WithMode(mode string) MessageOption

func WithParentMessageID added in v0.2.2

func WithParentMessageID(id string) MessageOption

func WithRawContent added in v0.2.25

func WithRawContent(content string) MessageOption

func WithRole added in v0.2.2

func WithRole(role string) MessageOption

Message content and semantics

func WithSequence added in v0.2.2

func WithSequence(v int) MessageOption

func WithStatus added in v0.2.2

func WithStatus(status string) MessageOption

func WithSupersededBy added in v0.2.2

func WithSupersededBy(id string) MessageOption

func WithTags added in v0.2.2

func WithTags(s string) MessageOption

func WithToolName added in v0.2.2

func WithToolName(name string) MessageOption

func WithTurnID added in v0.2.2

func WithTurnID(id string) MessageOption

func WithType added in v0.2.2

func WithType(typ string) MessageOption

func WithUpdatedAt added in v0.2.2

func WithUpdatedAt(t time.Time) MessageOption

type Messages

type Messages []*Message

func (Messages) LatestByCreatedAt added in v0.2.18

func (m Messages) LatestByCreatedAt() *Message

LatestByCreatedAt returns the last non-nil message by CreatedAt timestamp. When messages are empty or all nil, it returns nil.

func (Messages) SortByCreatedAt

func (m Messages) SortByCreatedAt(asc bool)

SortByCreatedAt sorts the messages in-place by CreatedAt. When asc is true, earlier messages come first; otherwise latest first.

func (Messages) SortedByCreatedAt

func (m Messages) SortedByCreatedAt(asc bool) Messages

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 MutableMessage

type MutableMessage = msgw.Message

func AddMessage added in v0.2.2

func AddMessage(ctx context.Context, cl Client, turn *memory.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

type MutableModelCall = mcall.ModelCall

func NewModelCall

func NewModelCall() *MutableModelCall

NewModelCall allocates a mutable model call with Has populated.

type MutablePayload

type MutablePayload = payloadw.Payload

func NewPayload

func NewPayload() *MutablePayload

NewPayload allocates a mutable payload with Has populated.

type MutableToolCall

type MutableToolCall = toolcall.ToolCall

func NewToolCall

func NewToolCall() *MutableToolCall

NewToolCall allocates a mutable tool call with Has populated.

type MutableTurn

type MutableTurn = turnw.Turn

func NewTurn

func NewTurn() *MutableTurn

NewTurn allocates a mutable turn with Has populated.

type Option

type Option func(input *Input)

func WithIncludeModelCall

func WithIncludeModelCall(include bool) Option

func WithIncludeToolCall

func WithIncludeToolCall(include bool) Option

func WithSince

func WithSince(since string) Option

WithSince sets the optional since parameter controlling transcript filtering.

func WithToolFeedSpec added in v0.2.1

func WithToolFeedSpec(ext []*tool.FeedSpec) Option

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 added in v0.2.25

type ResponsePayloadView = agconv.ResponsePayloadView

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 NewService(api Client) *Service

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 added in v0.2.25

type ToolCallView = agconv.ToolCallView

type Transcript

type Transcript []*Turn

func (*Transcript) Filter

func (t *Transcript) Filter(f func(v *Message) bool) Messages

func (*Transcript) History

func (t *Transcript) History(minimal bool) []*prompt.Message

func (Transcript) Last added in v0.2.2

func (t Transcript) Last() Transcript

func (*Transcript) LastAssistantMessage added in v0.2.18

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 added in v0.2.21

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 added in v0.2.21

func (t *Transcript) LastElicitationMessage() *Message

func (Transcript) UniqueToolNames added in v0.2.1

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.

type Turn

func (*Turn) Filter

func (t *Turn) Filter(f func(v *Message) bool) Messages

func (*Turn) GetMessages

func (t *Turn) GetMessages() Messages

func (*Turn) SetMessages added in v0.2.2

func (t *Turn) SetMessages(msg Messages)

func (*Turn) ToolCalls

func (t *Turn) ToolCalls() Messages

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL