agent

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Mar 13, 2026 License: MIT Imports: 32 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) DispatchNodeRequest

func (al *AgentLoop) DispatchNodeRequest(ctx context.Context, req nodes.Request, mode string) (nodes.Response, error)

func (*AgentLoop) GetSessionHistory

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

func (*AgentLoop) GetStartupInfo

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

func (*AgentLoop) GetToolCatalog

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

func (*AgentLoop) HandleSubagentRuntime

func (al *AgentLoop) HandleSubagentRuntime(ctx context.Context, action string, args map[string]interface{}) (interface{}, error)

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) SetConfigPath

func (al *AgentLoop) SetConfigPath(path string)

func (*AgentLoop) SetNodeP2PTransport

func (al *AgentLoop) SetNodeP2PTransport(t nodes.Transport)

func (*AgentLoop) Stop

func (al *AgentLoop) Stop()

type ContextBuilder

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

func NewContextBuilder

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

func (*ContextBuilder) AddAssistantMessage

func (cb *ContextBuilder) AddAssistantMessage(messages []providers.Message, content string, toolCalls []map[string]interface{}) []providers.Message

func (*ContextBuilder) AddToolResult

func (cb *ContextBuilder) AddToolResult(messages []providers.Message, toolCallID, toolName, result string) []providers.Message

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) BuildSystemPrompt

func (cb *ContextBuilder) BuildSystemPrompt() string

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 MemoryStore

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

MemoryStore manages persistent memory for the agent. - Long-term memory: MEMORY.md (workspace root, compatible with OpenClaw) - Daily notes: memory/YYYY-MM-DD.md It also supports legacy locations for backward compatibility.

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.

func (*MemoryStore) ReadToday

func (ms *MemoryStore) ReadToday() string

ReadToday reads today's daily note. Returns empty string if the file doesn't exist.

func (*MemoryStore) WriteLongTerm

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

WriteLongTerm writes content to the long-term memory file (MEMORY.md).

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)

func (*SessionScheduler) Close

func (s *SessionScheduler) Close()

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