Documentation
¶
Index ¶
- type Manager
- func (m *Manager) AddMessage(msg *schema.Message) error
- func (m *Manager) AddMessages(msgs []*schema.Message) error
- func (m *Manager) GetFilePath() string
- func (m *Manager) GetMessages() []*schema.Message
- func (m *Manager) GetSession() *Session
- func (m *Manager) MessageCount() int
- func (m *Manager) ReplaceAllMessages(msgs []*schema.Message) error
- func (m *Manager) Save() error
- func (m *Manager) SetMetadata(metadata Metadata) error
- type Message
- type Metadata
- type Session
- type ToolCall
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Manager ¶
type Manager struct {
// contains filtered or unexported fields
}
Manager manages session state and auto-saving
func NewManager ¶
NewManager creates a new session manager
func NewManagerWithSession ¶
NewManagerWithSession creates a new session manager with an existing session
func (*Manager) AddMessage ¶
AddMessage adds a message to the session and auto-saves
func (*Manager) AddMessages ¶
AddMessages adds multiple messages to the session and auto-saves
func (*Manager) GetFilePath ¶
GetFilePath returns the file path for this session
func (*Manager) GetMessages ¶
GetMessages returns all messages as schema.Message slice
func (*Manager) GetSession ¶
GetSession returns a copy of the current session
func (*Manager) MessageCount ¶
MessageCount returns the number of messages in the session
func (*Manager) ReplaceAllMessages ¶
ReplaceAllMessages replaces all messages in the session with the provided messages
func (*Manager) SetMetadata ¶
SetMetadata sets the session metadata
type Message ¶
type Message struct { ID string `json:"id"` Role string `json:"role"` Content string `json:"content"` Timestamp time.Time `json:"timestamp"` ToolCalls []ToolCall `json:"tool_calls,omitempty"` ToolCallID string `json:"tool_call_id,omitempty"` // For tool result messages }
Message represents a single message in the session
func ConvertFromSchemaMessage ¶
ConvertFromSchemaMessage converts a schema.Message to a session Message
func (*Message) ConvertToSchemaMessage ¶
ConvertToSchemaMessage converts a session Message to a schema.Message
type Metadata ¶
type Metadata struct { MCPHostVersion string `json:"mcphost_version"` Provider string `json:"provider"` Model string `json:"model"` }
Metadata contains session metadata
type Session ¶
type Session struct { Version string `json:"version"` CreatedAt time.Time `json:"created_at"` UpdatedAt time.Time `json:"updated_at"` Metadata Metadata `json:"metadata"` Messages []Message `json:"messages"` }
Session represents a complete conversation session with metadata
func LoadFromFile ¶
LoadFromFile loads a session from a JSON file
func (*Session) AddMessage ¶
AddMessage adds a message to the session
func (*Session) SaveToFile ¶
SaveToFile saves the session to a JSON file
func (*Session) SetMetadata ¶
SetMetadata sets the session metadata