screentracker

package
v0.7.1 Latest Latest
Warning

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

Go to latest
Published: Sep 15, 2025 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var MessageValidationErrorChanging = xerrors.New("message can only be sent when the agent is waiting for user input")
View Source
var MessageValidationErrorEmpty = xerrors.New("message must not be empty")
View Source
var MessageValidationErrorWhitespace = xerrors.New("message must be trimmed of leading and trailing whitespace")

Functions

func ExecuteParts

func ExecuteParts(writer AgentIO, parts ...MessagePart) error

func FindNewMessage

func FindNewMessage(oldScreen, newScreen string, agentType msgfmt.AgentType) string

func PartsToString

func PartsToString(parts ...MessagePart) string

Types

type AgentIO

type AgentIO interface {
	Write(data []byte) (int, error)
	ReadScreen() string
}

type Conversation

type Conversation struct {
	// contains filtered or unexported fields
}

func NewConversation

func NewConversation(ctx context.Context, cfg ConversationConfig) *Conversation

func (*Conversation) AddSnapshot

func (c *Conversation) AddSnapshot(screen string)

func (*Conversation) Messages

func (c *Conversation) Messages() []ConversationMessage

func (*Conversation) Screen

func (c *Conversation) Screen() string

func (*Conversation) SendMessage

func (c *Conversation) SendMessage(messageParts ...MessagePart) error

func (*Conversation) StartSnapshotLoop

func (c *Conversation) StartSnapshotLoop(ctx context.Context)

func (*Conversation) Status

func (c *Conversation) Status() ConversationStatus

type ConversationConfig

type ConversationConfig struct {
	AgentType msgfmt.AgentType
	AgentIO   AgentIO
	// GetTime returns the current time
	GetTime func() time.Time
	// How often to take a snapshot for the stability check
	SnapshotInterval time.Duration
	// How long the screen should not change to be considered stable
	ScreenStabilityLength time.Duration
	// Function to format the messages received from the agent
	// userInput is the last user message
	FormatMessage func(message string, userInput string) string
	// SkipWritingMessage skips the writing of a message to the agent.
	// This is used in tests
	SkipWritingMessage bool
	// SkipSendMessageStatusCheck skips the check for whether the message can be sent.
	// This is used in tests
	SkipSendMessageStatusCheck bool
}

type ConversationMessage

type ConversationMessage struct {
	Id      int
	Message string
	Role    ConversationRole
	Time    time.Time
}

type ConversationRole

type ConversationRole string
const (
	ConversationRoleUser  ConversationRole = "user"
	ConversationRoleAgent ConversationRole = "agent"
)

func (ConversationRole) Schema

func (c ConversationRole) Schema(r huma.Registry) *huma.Schema

type ConversationStatus

type ConversationStatus string
const (
	ConversationStatusChanging     ConversationStatus = "changing"
	ConversationStatusStable       ConversationStatus = "stable"
	ConversationStatusInitializing ConversationStatus = "initializing"
)

type MessagePart

type MessagePart interface {
	Do(writer AgentIO) error
	String() string
}

type MessagePartText

type MessagePartText struct {
	Content string
	Alias   string
	Hidden  bool
}

func (MessagePartText) Do

func (p MessagePartText) Do(writer AgentIO) error

func (MessagePartText) String

func (p MessagePartText) String() string

type RingBuffer

type RingBuffer[T any] struct {
	// contains filtered or unexported fields
}

RingBuffer is a generic circular buffer that can store items of any type

func NewRingBuffer

func NewRingBuffer[T any](size int) *RingBuffer[T]

NewRingBuffer creates a new ring buffer with the specified size

func (*RingBuffer[T]) Add

func (r *RingBuffer[T]) Add(item T)

Add adds an item to the ring buffer

func (*RingBuffer[T]) Capacity

func (b *RingBuffer[T]) Capacity() int

Capacity returns the capacity of the ring buffer

func (*RingBuffer[T]) GetAll

func (b *RingBuffer[T]) GetAll() []T

GetAll returns all items in the buffer, oldest first

Jump to

Keyboard shortcuts

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