Documentation
¶
Index ¶
- Constants
- func EventToJSON(event *storage.Event) string
- func ParsePriority(s string) storage.EventPriority
- type Agent
- func (a *Agent) AddPulseEvent(title, content string, priority int, channel string) (int64, error)
- func (a *Agent) Chat(messages []Message) string
- func (a *Agent) GetConfig() (apiKey, baseURL, model string)
- func (a *Agent) GetPulseStatus() (map[string]interface{}, error)
- func (a *Agent) MemoryStore() *memory.VectorMemoryStore
- func (a *Agent) Pulse() *PulseHandler
- func (a *Agent) Registry_() *tools.Registry
- func (a *Agent) Store() *storage.Storage
- func (a *Agent) ToolSpecs() []map[string]any
- func (a *Agent) UpdateConfig(apiKey, baseURL, model string)
- type ChatRequest
- type ChatResponse
- type Choice
- type Config
- type Message
- type PulseArgs
- type PulseConfig
- type PulseEvent
- type PulseHandler
- func (p *PulseHandler) AddEvent(title, content string, priority int, channel string) (int64, error)
- func (p *PulseHandler) GetStatus() map[string]interface{}
- func (p *PulseHandler) IsProcessing() bool
- func (p *PulseHandler) IsRunning() bool
- func (p *PulseHandler) SetBroadcastCallback(cb func(string, int) error)
- func (p *PulseHandler) SetEventCallback(cb func(*PulseEvent))
- func (p *PulseHandler) SetLLMCallback(cb func(string) (string, error))
- func (p *PulseHandler) Start()
- func (p *PulseHandler) Stop()
- type PulseReply
- type RPCService
- func (s *RPCService) Chat(args rpcproto.ChatArgs, reply *rpcproto.ChatReply) error
- func (s *RPCService) MemoryGet(args rpcproto.MemoryGetArgs, reply *rpcproto.ToolResultReply) error
- func (s *RPCService) MemorySearch(args rpcproto.MemorySearchArgs, reply *rpcproto.ToolResultReply) error
- func (s *RPCService) MemoryStore(args rpcproto.MemoryStoreArgs, reply *rpcproto.ToolResultReply) error
- func (s *RPCService) PulseAdd(args PulseArgs, reply *PulseReply) error
- func (s *RPCService) PulseStatus(args struct{}, reply *PulseReply) error
- func (s *RPCService) Stats(_ struct{}, reply *rpcproto.StatsReply) error
- type Session
- type SessionInfo
- type SessionManager
- func (sm *SessionManager) AddMessage(key string, msg Message) error
- func (sm *SessionManager) ClearSession(key string) error
- func (sm *SessionManager) CreateSession(key, agentID string) (*Session, error)
- func (sm *SessionManager) CreateSessionForChannel(channelType, channelID, agentID string) (*Session, error)
- func (sm *SessionManager) GetMessages(key string) ([]Message, error)
- func (sm *SessionManager) GetOrCreateChannelSession(channelType, channelID, agentID string) (*Session, error)
- func (sm *SessionManager) GetOrCreateSession(key, agentID string) (*Session, error)
- func (sm *SessionManager) GetSession(key string) (*Session, bool)
- func (sm *SessionManager) GetSessionInfo(key string) (*SessionInfo, error)
- func (sm *SessionManager) ListSessionInfos() []SessionInfo
- func (sm *SessionManager) ListSessions() []*Session
- func (sm *SessionManager) LoadSessions() error
- func (sm *SessionManager) RemoveSession(key string) error
- type SessionManagerWithRPC
- type SessionRPCClient
- type ToolCall
- type ToolResponse
- type ToolResult
Constants ¶
const ( CONFIG_SECTION = "llm" DEFAULT_CONTEXT_TOKENS = 8192 DEFAULT_RESERVE_TOKENS = 1024 DEFAULT_SOFT_TOKENS = 800 DEFAULT_KEEP_MESSAGES = 30 )
Variables ¶
This section is empty.
Functions ¶
func EventToJSON ¶
EventToJSON converts an event to JSON
func ParsePriority ¶
func ParsePriority(s string) storage.EventPriority
ParsePriority parses a priority string to EventPriority
Types ¶
type Agent ¶
type Agent struct {
// contains filtered or unexported fields
}
func (*Agent) AddPulseEvent ¶
AddPulseEvent adds a new event to the pulse system priority: 0=critical, 1=high, 2=normal, 3=low
func (*Agent) GetPulseStatus ¶
GetPulseStatus returns the current status of the pulse system
func (*Agent) MemoryStore ¶
func (a *Agent) MemoryStore() *memory.VectorMemoryStore
func (*Agent) Pulse ¶
func (a *Agent) Pulse() *PulseHandler
Pulse returns the pulse handler if available
func (*Agent) UpdateConfig ¶
type ChatRequest ¶
type ChatResponse ¶
type Config ¶
type Config struct {
APIKey string
BaseURL string
Model string
Storage *storage.Storage
MemoryStore *memory.VectorMemoryStore
Registry *tools.Registry
AutoRecall bool
RecallLimit int
RecallMinScore float64
// Pulse/Heartbeat system configuration
PulseEnabled bool
PulseConfig *PulseConfig
}
Config
type Message ¶
type Message struct {
Role string `json:"role"`
Content string `json:"content"`
ToolCalls []ToolCall `json:"tool_calls,omitempty"`
ToolCallID string `json:"tool_call_id,omitempty"`
ToolExecutionResults []ToolResult `json:"tool_results,omitempty"`
}
type PulseArgs ¶
type PulseArgs struct {
Action string // "add", "status", "list"
Title string
Content string
Priority int // 0-3
Channel string
Limit int
}
PulseArgs represents arguments for pulse operations
type PulseConfig ¶
type PulseConfig struct {
Interval time.Duration // Check interval (default 1 second)
Enabled bool // Enable/disable pulse
LLMEnabled bool // Enable LLM processing
MaxQueueSize int // Maximum events in queue
CleanupHours int // Hours after which to clear old events
}
PulseConfig holds configuration for the heartbeat system
func DefaultPulseConfig ¶
func DefaultPulseConfig() *PulseConfig
DefaultPulseConfig returns default configuration
type PulseEvent ¶
PulseEvent represents an event to be processed by the heartbeat system
type PulseHandler ¶
type PulseHandler struct {
// contains filtered or unexported fields
}
PulseHandler handles the heartbeat/pulse system
func NewPulseHandler ¶
func NewPulseHandler(storage *storage.Storage, config *PulseConfig) *PulseHandler
NewPulseHandler creates a new pulse handler
func (*PulseHandler) GetStatus ¶
func (p *PulseHandler) GetStatus() map[string]interface{}
GetStatus returns the current status of the pulse system
func (*PulseHandler) IsProcessing ¶
func (p *PulseHandler) IsProcessing() bool
IsProcessing returns whether currently processing an event
func (*PulseHandler) IsRunning ¶
func (p *PulseHandler) IsRunning() bool
IsRunning returns whether the pulse is running
func (*PulseHandler) SetBroadcastCallback ¶
func (p *PulseHandler) SetBroadcastCallback(cb func(string, int) error)
SetBroadcastCallback sets the callback for broadcasting messages
func (*PulseHandler) SetEventCallback ¶
func (p *PulseHandler) SetEventCallback(cb func(*PulseEvent))
SetEventCallback sets the callback for event processing
func (*PulseHandler) SetLLMCallback ¶
func (p *PulseHandler) SetLLMCallback(cb func(string) (string, error))
SetLLMCallback sets the callback for LLM processing
type PulseReply ¶
PulseReply represents the result of pulse operations
type RPCService ¶
type RPCService struct {
// contains filtered or unexported fields
}
func NewRPCService ¶
func NewRPCService(a *Agent) *RPCService
func (*RPCService) MemoryGet ¶
func (s *RPCService) MemoryGet(args rpcproto.MemoryGetArgs, reply *rpcproto.ToolResultReply) error
func (*RPCService) MemorySearch ¶
func (s *RPCService) MemorySearch(args rpcproto.MemorySearchArgs, reply *rpcproto.ToolResultReply) error
func (*RPCService) MemoryStore ¶
func (s *RPCService) MemoryStore(args rpcproto.MemoryStoreArgs, reply *rpcproto.ToolResultReply) error
func (*RPCService) PulseAdd ¶
func (s *RPCService) PulseAdd(args PulseArgs, reply *PulseReply) error
PulseAdd adds a new pulse event
func (*RPCService) PulseStatus ¶
func (s *RPCService) PulseStatus(args struct{}, reply *PulseReply) error
PulseStatus returns the current pulse system status
func (*RPCService) Stats ¶
func (s *RPCService) Stats(_ struct{}, reply *rpcproto.StatsReply) error
type Session ¶
type Session struct {
ID string
Key string // Unique session key (e.g., "main", "cron:job-123", "telegram:user-456")
AgentID string // Agent instance ID
Messages []Message // Conversation history
CreatedAt time.Time
UpdatedAt time.Time
TotalTokens int
CompactionCount int
ContextTokens int
IsActive bool
Metadata map[string]interface{}
// contains filtered or unexported fields
}
Session represents a conversation session
type SessionInfo ¶
type SessionInfo struct {
Key string `json:"key"`
AgentID string `json:"agentId"`
MessageCount int `json:"messageCount"`
TotalTokens int `json:"totalTokens"`
CreatedAt time.Time `json:"createdAt"`
UpdatedAt time.Time `json:"updatedAt"`
IsActive bool `json:"isActive"`
}
SessionInfo returns basic session info for listing
type SessionManager ¶
type SessionManager struct {
// contains filtered or unexported fields
}
SessionManager manages multiple sessions
func NewSessionManager ¶
func NewSessionManager(store *storage.Storage, defaultAgentID string) *SessionManager
NewSessionManager creates a new session manager
func (*SessionManager) AddMessage ¶
func (sm *SessionManager) AddMessage(key string, msg Message) error
AddMessage adds a message to a session
func (*SessionManager) ClearSession ¶
func (sm *SessionManager) ClearSession(key string) error
ClearSession clears a session's messages
func (*SessionManager) CreateSession ¶
func (sm *SessionManager) CreateSession(key, agentID string) (*Session, error)
CreateSession creates a new session
func (*SessionManager) CreateSessionForChannel ¶
func (sm *SessionManager) CreateSessionForChannel(channelType, channelID, agentID string) (*Session, error)
CreateSessionForChannel creates a session for a specific channel
func (*SessionManager) GetMessages ¶
func (sm *SessionManager) GetMessages(key string) ([]Message, error)
GetMessages returns all messages in a session
func (*SessionManager) GetOrCreateChannelSession ¶
func (sm *SessionManager) GetOrCreateChannelSession(channelType, channelID, agentID string) (*Session, error)
GetOrCreateChannelSession gets or creates a session for a channel
func (*SessionManager) GetOrCreateSession ¶
func (sm *SessionManager) GetOrCreateSession(key, agentID string) (*Session, error)
GetOrCreateSession returns existing session or creates new one
func (*SessionManager) GetSession ¶
func (sm *SessionManager) GetSession(key string) (*Session, bool)
GetSession returns a session by key
func (*SessionManager) GetSessionInfo ¶
func (sm *SessionManager) GetSessionInfo(key string) (*SessionInfo, error)
GetSessionInfo returns session info
func (*SessionManager) ListSessionInfos ¶
func (sm *SessionManager) ListSessionInfos() []SessionInfo
ListSessionInfos returns all session infos
func (*SessionManager) ListSessions ¶
func (sm *SessionManager) ListSessions() []*Session
ListSessions returns all active sessions
func (*SessionManager) LoadSessions ¶
func (sm *SessionManager) LoadSessions() error
LoadSessions loads sessions from database
func (*SessionManager) RemoveSession ¶
func (sm *SessionManager) RemoveSession(key string) error
RemoveSession removes a session
type SessionManagerWithRPC ¶
type SessionManagerWithRPC struct {
*SessionManager
// contains filtered or unexported fields
}
SessionManagerWithRPC extends SessionManager with RPC capabilities
func NewSessionManagerWithRPC ¶
func NewSessionManagerWithRPC(store *storage.Storage, defaultAgentID string) *SessionManagerWithRPC
NewSessionManagerWithRPC creates a new session manager with RPC
func (*SessionManagerWithRPC) ForwardToAgent ¶
func (sm *SessionManagerWithRPC) ForwardToAgent(targetAgentID string, messages []Message) (string, error)
ForwardToAgent forwards a message to another agent via RPC
func (*SessionManagerWithRPC) GetAgentRPC ¶
func (sm *SessionManagerWithRPC) GetAgentRPC(agentID string) (*SessionRPCClient, bool)
GetAgentRPC returns an RPC client for an agent
func (*SessionManagerWithRPC) RegisterAgentRPC ¶
func (sm *SessionManagerWithRPC) RegisterAgentRPC(agentID, address string)
RegisterAgentRPC registers an RPC client for an agent
type SessionRPCClient ¶
type SessionRPCClient struct {
// contains filtered or unexported fields
}
SessionRPCClient represents a client for making RPC calls to other agents
func NewSessionRPCClient ¶
func NewSessionRPCClient(agentID, address string) *SessionRPCClient
NewSessionRPCClient creates a new session RPC client
func (*SessionRPCClient) Connect ¶
func (c *SessionRPCClient) Connect() error
Connect connects to the agent
func (*SessionRPCClient) IsConnected ¶
func (c *SessionRPCClient) IsConnected() bool
IsConnected returns connection status
type ToolResponse ¶
type ToolResponse struct {
ToolResults []ToolResult `json:"tool_results"`
}