Documentation
¶
Index ¶
- type AgentInstance
- type AgentLoop
- func (al *AgentLoop) GetBlackboard() *blackboard.Blackboard
- func (al *AgentLoop) GetRegistry() *AgentRegistry
- func (al *AgentLoop) GetStartupInfo() map[string]any
- func (al *AgentLoop) GetTierRouter() *routing.TierRouter
- func (al *AgentLoop) ProcessDirect(ctx context.Context, content, sessionKey string) (string, error)
- func (al *AgentLoop) ProcessDirectWithChannel(ctx context.Context, content, sessionKey, channel, chatID string) (string, error)
- func (al *AgentLoop) ProcessHeartbeat(ctx context.Context, content, channel, chatID string) (string, error)
- func (al *AgentLoop) RecordLastChannel(channel string) error
- func (al *AgentLoop) RecordLastChatID(chatID string) error
- func (al *AgentLoop) RegisterTool(tool tools.Tool)
- func (al *AgentLoop) Run(ctx context.Context) error
- func (al *AgentLoop) SetChannelManager(cm *channels.Manager)
- func (al *AgentLoop) Stop()
- type AgentRegistry
- func (r *AgentRegistry) CanSpawnSubagent(parentAgentID, targetAgentID string) bool
- func (r *AgentRegistry) GetAgent(agentID string) (*AgentInstance, bool)
- func (r *AgentRegistry) GetDefaultAgent() *AgentInstance
- func (r *AgentRegistry) ListAgentIDs() []string
- func (r *AgentRegistry) ResolveRoute(input routing.RouteInput) routing.ResolvedRoute
- type ContextBuilder
- func (cb *ContextBuilder) AddAssistantMessage(messages []providers.Message, content string, toolCalls []map[string]any) []providers.Message
- func (cb *ContextBuilder) AddToolResult(messages []providers.Message, toolCallID, toolName, result string) []providers.Message
- func (cb *ContextBuilder) BuildMessages(history []providers.Message, summary string, currentMessage string, ...) []providers.Message
- func (cb *ContextBuilder) BuildSystemPrompt() string
- func (cb *ContextBuilder) BuildSystemPromptWithCache() string
- func (cb *ContextBuilder) GetSkillsInfo() map[string]any
- func (cb *ContextBuilder) InvalidateCache()
- func (cb *ContextBuilder) LoadBootstrapFiles() string
- func (cb *ContextBuilder) SetRuntimeContextFunc(fn func() string)
- func (cb *ContextBuilder) SetWorkflowContextFunc(fn func() string)
- type MemoryStore
- func (ms *MemoryStore) AppendToday(content string) error
- func (ms *MemoryStore) GetMemoryContext() string
- func (ms *MemoryStore) GetRecentDailyNotes(days int) string
- func (ms *MemoryStore) ReadLongTerm() string
- func (ms *MemoryStore) ReadToday() string
- func (ms *MemoryStore) WriteLongTerm(content string) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AgentInstance ¶
type AgentInstance struct {
ID string
Name string
Model string
Fallbacks []string
Workspace string
MaxIterations int
MaxTokens int
Temperature float64
ContextWindow int
Provider providers.LLMProvider
Sessions *session.SessionManager
ContextBuilder *ContextBuilder
Tools *tools.ToolRegistry
Subagents *config.SubagentsConfig
SkillsFilter []string
Candidates []providers.FallbackCandidate
WorkflowEngine *workflow.Engine // Optional workflow/mission state
CLAWAdapter *integration.CLAWAdapter // Optional CLAW orchestrator adapter
}
AgentInstance represents a fully configured agent with its own workspace, session manager, context builder, and tool registry.
func NewAgentInstance ¶
func NewAgentInstance( agentCfg *config.AgentConfig, defaults *config.AgentDefaults, cfg *config.Config, provider providers.LLMProvider, ) *AgentInstance
NewAgentInstance creates an agent instance from config.
func (*AgentInstance) LoadExistingMission ¶
func (ai *AgentInstance) LoadExistingMission(workflowName string, stateFile string) error
LoadExistingMission loads an existing mission state from disk.
func (*AgentInstance) LoadWorkflow ¶
func (ai *AgentInstance) LoadWorkflow(workflowName string, target string) error
LoadWorkflow loads a workflow definition and creates a new mission. Returns error if workflow cannot be loaded or mission already exists for target.
func (*AgentInstance) UnloadWorkflow ¶
func (ai *AgentInstance) UnloadWorkflow()
UnloadWorkflow clears the workflow engine and stops injecting workflow context.
type AgentLoop ¶
type AgentLoop struct {
// contains filtered or unexported fields
}
func NewAgentLoop ¶
func NewAgentLoop(cfg *config.Config, msgBus *bus.MessageBus, provider providers.LLMProvider) *AgentLoop
func (*AgentLoop) GetBlackboard ¶
func (al *AgentLoop) GetBlackboard() *blackboard.Blackboard
GetBlackboard returns the shared runtime blackboard.
func (*AgentLoop) GetRegistry ¶
func (al *AgentLoop) GetRegistry() *AgentRegistry
GetRegistry returns the agent registry
func (*AgentLoop) GetStartupInfo ¶
GetStartupInfo returns information about loaded tools, skills, and model for logging.
func (*AgentLoop) GetTierRouter ¶
func (al *AgentLoop) GetTierRouter() *routing.TierRouter
GetTierRouter returns the tier router if enabled
func (*AgentLoop) ProcessDirect ¶
func (*AgentLoop) ProcessDirectWithChannel ¶
func (*AgentLoop) ProcessHeartbeat ¶
func (al *AgentLoop) ProcessHeartbeat(ctx context.Context, content, channel, chatID string) (string, error)
ProcessHeartbeat processes a heartbeat request without session history. Each heartbeat is independent and doesn't accumulate context.
func (*AgentLoop) RecordLastChannel ¶
RecordLastChannel records the last active channel for this workspace. This uses the atomic state save mechanism to prevent data loss on crash.
func (*AgentLoop) RecordLastChatID ¶
RecordLastChatID records the last active chat ID for this workspace. This uses the atomic state save mechanism to prevent data loss on crash.
func (*AgentLoop) RegisterTool ¶
func (*AgentLoop) SetChannelManager ¶
type AgentRegistry ¶
type AgentRegistry struct {
// contains filtered or unexported fields
}
AgentRegistry manages multiple agent instances and routes messages to them.
func NewAgentRegistry ¶
func NewAgentRegistry( cfg *config.Config, provider providers.LLMProvider, ) *AgentRegistry
NewAgentRegistry creates a registry from config, instantiating all agents.
func (*AgentRegistry) CanSpawnSubagent ¶
func (r *AgentRegistry) CanSpawnSubagent(parentAgentID, targetAgentID string) bool
CanSpawnSubagent checks if parentAgentID is allowed to spawn targetAgentID.
func (*AgentRegistry) GetAgent ¶
func (r *AgentRegistry) GetAgent(agentID string) (*AgentInstance, bool)
GetAgent returns the agent instance for a given ID.
func (*AgentRegistry) GetDefaultAgent ¶
func (r *AgentRegistry) GetDefaultAgent() *AgentInstance
GetDefaultAgent returns the default agent instance.
func (*AgentRegistry) ListAgentIDs ¶
func (r *AgentRegistry) ListAgentIDs() []string
ListAgentIDs returns all registered agent IDs.
func (*AgentRegistry) ResolveRoute ¶
func (r *AgentRegistry) ResolveRoute(input routing.RouteInput) routing.ResolvedRoute
ResolveRoute determines which agent handles the message.
type ContextBuilder ¶
type ContextBuilder struct {
// contains filtered or unexported fields
}
func NewContextBuilder ¶
func NewContextBuilder(workspace string) *ContextBuilder
func (*ContextBuilder) AddAssistantMessage ¶
func (*ContextBuilder) AddToolResult ¶
func (*ContextBuilder) BuildMessages ¶
func (*ContextBuilder) BuildSystemPrompt ¶
func (cb *ContextBuilder) BuildSystemPrompt() string
func (*ContextBuilder) BuildSystemPromptWithCache ¶
func (cb *ContextBuilder) BuildSystemPromptWithCache() string
BuildSystemPromptWithCache returns the cached system prompt if available and source files haven't changed, otherwise builds and caches it. Source file changes are detected via mtime checks (cheap stat calls).
func (*ContextBuilder) GetSkillsInfo ¶
func (cb *ContextBuilder) GetSkillsInfo() map[string]any
GetSkillsInfo returns information about loaded skills.
func (*ContextBuilder) InvalidateCache ¶
func (cb *ContextBuilder) InvalidateCache()
InvalidateCache clears the cached system prompt. Normally not needed because the cache auto-invalidates via mtime checks, but this is useful for tests or explicit reload commands.
func (*ContextBuilder) LoadBootstrapFiles ¶
func (cb *ContextBuilder) LoadBootstrapFiles() string
func (*ContextBuilder) SetRuntimeContextFunc ¶
func (cb *ContextBuilder) SetRuntimeContextFunc(fn func() string)
SetRuntimeContextFunc sets a function to provide compact dynamic runtime context.
func (*ContextBuilder) SetWorkflowContextFunc ¶
func (cb *ContextBuilder) SetWorkflowContextFunc(fn func() string)
SetWorkflowContextFunc sets a function to provide workflow context for the system prompt. This allows the agent loop to inject mission/workflow state without tight coupling.
type MemoryStore ¶
type MemoryStore struct {
// contains filtered or unexported fields
}
MemoryStore manages persistent memory for the agent. - Long-term memory: memory/MEMORY.md - Daily notes: memory/YYYYMM/YYYYMMDD.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 (*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).