agent

package
v0.1.3 Latest Latest
Warning

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

Go to latest
Published: Aug 2, 2026 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AppendToolRound

func AppendToolRound(
	messages []llm.Message,
	assistantText string,
	toolCalls []llm.ToolCall,
	results []llm.ToolResult,
) []llm.Message

func BuildContext

func BuildContext(mem *Memory, history []ChatEntry, userMsg string) []llm.Message

func GenerateTitle

func GenerateTitle(
	sup *concurrency.Supervisor,
	parent context.Context,
	llmClient *llm.Client,
	session *Session,
	firstUserMsg string,
)

Types

type Agent

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

func NewAgent

func NewAgent(
	parent context.Context,
	llmClient *llm.Client,
	dockerClient *docker.Client,
	session *Session,
	supervisor *concurrency.Supervisor,
	agentBusy *atomic.Bool,
	tokenCount *atomic.Int64,
) *Agent

func (*Agent) Run

func (a *Agent) Run(userMsg string)

func (*Agent) SetProgram

func (a *Agent) SetProgram(p *tea.Program)

func (*Agent) Stop

func (a *Agent) Stop()

func (*Agent) SubmitAskUserReply

func (a *Agent) SubmitAskUserReply(reply AskUserReply)

type AgentChunkMsg

type AgentChunkMsg struct{ Text string }

type AgentDoneMsg

type AgentDoneMsg struct{ Err error }

type AskUserMsg

type AskUserMsg struct {
	Question string
	Options  []string
	Fields   []tools.AskUserField
}

type AskUserReply

type AskUserReply struct {
	Answer map[string]string
}

type ChatEntry

type ChatEntry struct {
	Role      string    `json:"role"`
	Content   string    `json:"content"`
	Timestamp time.Time `json:"timestamp"`
}

type DispatchResult

type DispatchResult struct {
	FullText  string
	ToolCalls []llm.ToolCall
	Error     error
}

type Memory

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

func NewMemory

func NewMemory(s *Session) *Memory

func (*Memory) AppendToSection

func (m *Memory) AppendToSection(section, content string)

func (*Memory) BuildSystemPrompt

func (m *Memory) BuildSystemPrompt() string

func (*Memory) GetSection

func (m *Memory) GetSection(section string) string

func (*Memory) SetSection

func (m *Memory) SetSection(section, content string)

type Session

type Session struct {
	ID   string
	Dir  string
	Meta SessionMeta
	// contains filtered or unexported fields
}

func LoadSession

func LoadSession(parent context.Context, dir string) (*Session, error)

func NewSession

func NewSession(parent context.Context, baseDir string) (*Session, error)

func (*Session) AppendChat

func (s *Session) AppendChat(role, content string, toolCalls interface{})

func (*Session) GetAgentMD

func (s *Session) GetAgentMD() string

func (*Session) GetChatLog

func (s *Session) GetChatLog() []ChatEntry

func (*Session) GetMeta

func (s *Session) GetMeta() SessionMeta

func (*Session) Save

func (s *Session) Save() error

func (*Session) SetTitle

func (s *Session) SetTitle(title string)

func (*Session) Stop

func (s *Session) Stop()

func (*Session) UpdateAgentMD

func (s *Session) UpdateAgentMD(content string)

type SessionIndex

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

func NewSessionIndex

func NewSessionIndex(baseDir string) (*SessionIndex, error)

func (*SessionIndex) Delete

func (i *SessionIndex) Delete(id string) error

func (*SessionIndex) List

func (i *SessionIndex) List() []SessionSummary

func (*SessionIndex) Upsert

func (i *SessionIndex) Upsert(s SessionSummary) error

type SessionMeta

type SessionMeta struct {
	ID        string    `json:"id"`
	Title     string    `json:"title"`
	CreatedAt time.Time `json:"created_at"`
	UpdatedAt time.Time `json:"updated_at"`
	TokensIn  int       `json:"tokens_in"`
	TokensOut int       `json:"tokens_out"`
	Tags      []string  `json:"tags"`
}

type SessionSummary

type SessionSummary struct {
	ID        string   `json:"id"`
	Title     string   `json:"title"`
	UpdatedAt string   `json:"updated_at"`
	TokensIn  int      `json:"tokens_in"`
	TokensOut int      `json:"tokens_out"`
	Tags      []string `json:"tags"`
}

type SidebarRefreshMsg

type SidebarRefreshMsg struct {
	Containers []docker.Container
	Images     []docker.Image
	Volumes    []docker.Volume
	Networks   []docker.Network
}

type StreamDispatcher

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

func NewStreamDispatcher

func NewStreamDispatcher(
	onText func(string),
	onToolStart func(id, name string),
	onToolChunk func(id, chunk string),
	onToolEnd func(id string),
) *StreamDispatcher

func (*StreamDispatcher) Run

func (d *StreamDispatcher) Run(ctx context.Context, deltaCh <-chan llm.Delta) DispatchResult

type ToolDoneMsg

type ToolDoneMsg struct {
	Name   string
	Result string
	Err    error
}

type ToolStartMsg

type ToolStartMsg struct {
	Name string
	Args string
}

Jump to

Keyboard shortcuts

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