agent

package
v1.2.10 Latest Latest
Warning

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

Go to latest
Published: May 11, 2026 License: MIT Imports: 29 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DetectResponseLanguage

func DetectResponseLanguage(userText, preferred, last string) string

DetectResponseLanguage returns a BCP-47 style language tag for reply policy. Priority: explicit preference > current user text > last session language > default English.

func ExtractLanguagePreference

func ExtractLanguagePreference(text string) string

ExtractLanguagePreference detects explicit user instructions for language switch.

Types

type AgentLoop

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

func NewAgentLoop

func NewAgentLoop(cfg *config.Config, msgBus *bus.MessageBus, provider providers.LLMProvider, cs *cron.CronService) *AgentLoop

func (*AgentLoop) DispatchSubagentAndWait added in v1.0.0

func (al *AgentLoop) DispatchSubagentAndWait(ctx context.Context, req tools.RouterDispatchRequest, waitTimeout time.Duration) (string, error)

func (*AgentLoop) GetSessionHistory

func (al *AgentLoop) GetSessionHistory(sessionKey string) []providers.Message

func (*AgentLoop) GetSessionHistoryWindow added in v1.1.0

func (al *AgentLoop) GetSessionHistoryWindow(sessionKey string, around, before, after, limit int) []providers.Message

func (*AgentLoop) GetStartupInfo

func (al *AgentLoop) GetStartupInfo() map[string]interface{}

func (*AgentLoop) GetToolCatalog

func (al *AgentLoop) GetToolCatalog() []map[string]interface{}

func (*AgentLoop) ProcessDirect

func (al *AgentLoop) ProcessDirect(ctx context.Context, content, sessionKey string) (string, error)

func (*AgentLoop) ProcessDirectWithOptions

func (al *AgentLoop) ProcessDirectWithOptions(ctx context.Context, content, sessionKey, channel, chatID, memoryNamespace string, toolAllowlist []string) (string, error)

func (*AgentLoop) Run

func (al *AgentLoop) Run(ctx context.Context) error

func (*AgentLoop) RunStartupSelfCheckAllSessions

func (al *AgentLoop) RunStartupSelfCheckAllSessions(ctx context.Context) StartupCompactionReport

RunStartupSelfCheckAllSessions runs startup compaction checks across loaded sessions.

func (*AgentLoop) SearchSessions added in v1.1.0

func (al *AgentLoop) SearchSessions(query string, kinds []string, excludeKey string, limit int) []session.SessionSearchResult

func (*AgentLoop) SetConfigPath

func (al *AgentLoop) SetConfigPath(path string)

func (*AgentLoop) SetContextEngine added in v1.2.0

func (al *AgentLoop) SetContextEngine(engine ContextEngine)

func (*AgentLoop) Stop

func (al *AgentLoop) Stop()

type ContextBuildRequest added in v1.2.0

type ContextBuildRequest struct {
	History          []providers.Message
	Summary          string
	CurrentMessage   string
	Media            []string
	Channel          string
	ChatID           string
	ResponseLanguage string
	MemoryNamespace  string
}

ContextBuildRequest defines inputs for building a provider message window.

type ContextBuilder

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

func NewContextBuilder

func NewContextBuilder(workspace string, toolsSummaryFunc func() []string) *ContextBuilder

func (*ContextBuilder) BuildMessages

func (cb *ContextBuilder) BuildMessages(history []providers.Message, summary string, currentMessage string, media []string, channel, chatID, responseLanguage string) []providers.Message

func (*ContextBuilder) BuildMessagesWithMemoryNamespace

func (cb *ContextBuilder) BuildMessagesWithMemoryNamespace(history []providers.Message, summary string, currentMessage string, media []string, channel, chatID, responseLanguage, memoryNamespace string) []providers.Message

func (*ContextBuilder) BuildSystemPromptWithMemoryNamespace

func (cb *ContextBuilder) BuildSystemPromptWithMemoryNamespace(memoryNamespace string) string

func (*ContextBuilder) GetSkillsInfo

func (cb *ContextBuilder) GetSkillsInfo() map[string]interface{}

GetSkillsInfo returns information about loaded skills.

func (*ContextBuilder) LoadBootstrapFiles

func (cb *ContextBuilder) LoadBootstrapFiles() string

func (*ContextBuilder) LoadProjectPlanningFiles

func (cb *ContextBuilder) LoadProjectPlanningFiles() string

type ContextEngine added in v1.2.0

type ContextEngine interface {
	BuildMessages(req ContextBuildRequest) []providers.Message
	SkillsInfo() map[string]interface{}
}

ContextEngine allows swapping context-assembly behavior without touching AgentLoop flow.

func NewDefaultContextEngine added in v1.2.0

func NewDefaultContextEngine(builder *ContextBuilder) ContextEngine

type MemoryStore

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

MemoryStore manages persistent memory for the agent. - Long-term memory: MEMORY.md - Daily notes: memory/YYYY-MM-DD.md

func NewMemoryStore

func NewMemoryStore(workspace string) *MemoryStore

NewMemoryStore creates a new MemoryStore with the given workspace path. It ensures the memory directory exists.

func NewMemoryStoreWithNamespace

func NewMemoryStoreWithNamespace(workspace, namespace string) *MemoryStore

func (*MemoryStore) AppendToday

func (ms *MemoryStore) AppendToday(content string) error

AppendToday appends content to today's daily note. If the file doesn't exist, it creates a new file with a date header.

func (*MemoryStore) GetMemoryContext

func (ms *MemoryStore) GetMemoryContext() string

GetMemoryContext returns formatted memory context for the agent prompt. Includes long-term memory and recent daily notes.

func (*MemoryStore) GetRecentDailyNotes

func (ms *MemoryStore) GetRecentDailyNotes(days int) string

GetRecentDailyNotes returns daily notes from the last N days. Contents are joined with "---" separator.

func (*MemoryStore) ReadLongTerm

func (ms *MemoryStore) ReadLongTerm() string

ReadLongTerm reads the long-term memory (MEMORY.md). Returns empty string if the file doesn't exist.

type SessionScheduler

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

func NewSessionScheduler

func NewSessionScheduler(maxParallel int) *SessionScheduler

func (*SessionScheduler) Acquire

func (s *SessionScheduler) Acquire(ctx context.Context, sessionKey string, keys []string) (func(), error)

type StartupCompactionReport

type StartupCompactionReport struct {
	TotalSessions     int `json:"total_sessions"`
	CompactedSessions int `json:"compacted_sessions"`
}

StartupCompactionReport provides startup memory/session maintenance stats.

type TriggerStats

type TriggerStats struct {
	UpdatedAt string         `json:"updated_at"`
	Counts    map[string]int `json:"counts"`
}

Jump to

Keyboard shortcuts

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