conversation

package
v0.3.5 Latest Latest
Warning

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

Go to latest
Published: Oct 22, 2025 License: MIT Imports: 8 Imported by: 0

Documentation

Overview

Package conversation provides conversation state management for AgentPipe. It enables saving and resuming conversations across sessions.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GenerateStateFileName

func GenerateStateFileName() string

GenerateStateFileName generates a filename for a conversation state. Format: conversation-YYYYMMDD-HHMMSS.json

func GetDefaultStateDir

func GetDefaultStateDir() (string, error)

GetDefaultStateDir returns the default directory for saving conversation states. This is ~/.agentpipe/states by default.

func ListStates

func ListStates(dir string) ([]string, error)

ListStates lists all saved conversation states in a directory.

Types

type State

type State struct {
	// Version is the state file format version
	Version string `json:"version"`

	// SavedAt is when the state was saved
	SavedAt time.Time `json:"saved_at"`

	// Messages is the conversation history
	Messages []agent.Message `json:"messages"`

	// Config is the configuration used for this conversation
	Config *config.Config `json:"config"`

	// Metadata contains additional information about the conversation
	Metadata StateMetadata `json:"metadata"`
}

State represents a saved conversation state. It contains all information needed to resume a conversation.

func LoadState

func LoadState(path string) (*State, error)

LoadState loads a conversation state from a file.

func NewState

func NewState(messages []agent.Message, cfg *config.Config, startedAt time.Time) *State

NewState creates a new conversation state.

func (*State) Save

func (s *State) Save(path string) error

Save writes the conversation state to a file. The file is created with 0600 permissions (read/write for owner only).

type StateInfo

type StateInfo struct {
	Path        string
	SavedAt     time.Time
	StartedAt   time.Time
	Messages    int
	Turns       int
	Description string
	AgentCount  int
	Mode        string
}

StateInfo contains summary information about a saved state.

func GetStateInfo

func GetStateInfo(path string) (*StateInfo, error)

GetStateInfo reads summary information from a state file without loading full state.

type StateMetadata

type StateMetadata struct {
	// TotalTurns is the number of conversation turns completed
	TotalTurns int `json:"total_turns"`

	// TotalMessages is the total number of messages
	TotalMessages int `json:"total_messages"`

	// TotalDuration is the total conversation duration in milliseconds
	TotalDuration int64 `json:"total_duration_ms"`

	// StartedAt is when the conversation was started
	StartedAt time.Time `json:"started_at"`

	// Description is an optional description of the conversation
	Description string `json:"description,omitempty"`
}

StateMetadata contains metadata about a saved conversation state.

Jump to

Keyboard shortcuts

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