Documentation
¶
Index ¶
- type AgentCapability
- type AgentMessage
- type AgentStatus
- type Config
- type Fact
- type Feature
- type FeatureStatus
- type Handoff
- type HandoffMessage
- type HandoffProtocol
- func (hp *HandoffProtocol) BuildHandoffContext(from, to string, task string) *HandoffMessage
- func (hp *HandoffProtocol) CanHandle(agentName, task string) bool
- func (hp *HandoffProtocol) EscalateToHuman(reason string) *HandoffMessage
- func (hp *HandoffProtocol) FormatHandoffHistory() string
- func (hp *HandoffProtocol) GetActiveAgent() *AgentCapability
- func (hp *HandoffProtocol) Handoff(msg HandoffMessage) error
- func (hp *HandoffProtocol) RegisterAgent(cap AgentCapability)
- func (hp *HandoffProtocol) SelectBestAgent(task string) string
- type Ledger
- type LedgerOrchestrator
- func (lo *LedgerOrchestrator) AddFact(content, source string, confidence float64)
- func (lo *LedgerOrchestrator) AddPlanItem(description string, deps []string)
- func (lo *LedgerOrchestrator) AssignNext() (*PlanItem, string)
- func (lo *LedgerOrchestrator) DetectStall() bool
- func (lo *LedgerOrchestrator) FormatLedger() string
- func (lo *LedgerOrchestrator) Reassign(itemID string) string
- func (lo *LedgerOrchestrator) RegisterAgent(name string)
- func (lo *LedgerOrchestrator) ReportProgress(agentName string, itemID string, status string)
- func (lo *LedgerOrchestrator) UpdatePlan(newItems []PlanItem)
- type MemEntry
- type MessageBus
- func (mb *MessageBus) Broadcast(from, topic, content string)
- func (mb *MessageBus) BuildContextFromMessages(agentID string, maxTokens int) string
- func (mb *MessageBus) GetHistory(topic string, limit int) []AgentMessage
- func (mb *MessageBus) Register(agentID string) <-chan AgentMessage
- func (mb *MessageBus) ReportConflict(from string, files []string, description string)
- func (mb *MessageBus) ReportDiscovery(from, discovery string)
- func (mb *MessageBus) ReportProgress(from string, pct float64, status string)
- func (mb *MessageBus) RequestHelp(from, description string) string
- func (mb *MessageBus) Send(msg AgentMessage) error
- func (mb *MessageBus) Subscribe(agentID, topic string)
- func (mb *MessageBus) Unregister(agentID string)
- func (mb *MessageBus) WaitForResponse(messageID string, timeout time.Duration) (*AgentMessage, error)
- type Mission
- type PlanFunc
- type PlanItem
- type SharedMemory
- func (sm *SharedMemory) Clear()
- func (sm *SharedMemory) Delete(key string, owner string) error
- func (sm *SharedMemory) Diff(since time.Time) []MemEntry
- func (sm *SharedMemory) FormatState() string
- func (sm *SharedMemory) Get(key string) (interface{}, bool)
- func (sm *SharedMemory) GetBool(key string) bool
- func (sm *SharedMemory) GetInt(key string) int
- func (sm *SharedMemory) GetString(key string) string
- func (sm *SharedMemory) List(namespace string) []MemEntry
- func (sm *SharedMemory) Restore(snapshot map[string]interface{})
- func (sm *SharedMemory) Set(key string, value interface{}, owner string)
- func (sm *SharedMemory) SetNamespace(key, namespace string)
- func (sm *SharedMemory) Snapshot() map[string]interface{}
- func (sm *SharedMemory) Watch(key string) <-chan *MemEntry
- type Status
- type WorkerFunc
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AgentCapability ¶
type AgentCapability struct {
Name string
Expertise []string
Tools []string
MaxComplexity int
Model string
}
AgentCapability describes a specialized agent's capabilities.
type AgentMessage ¶
type AgentMessage struct {
ID string `json:"id"`
From string `json:"from"`
To string `json:"to,omitempty"`
Topic string `json:"topic"`
Content string `json:"content"`
Priority int `json:"priority"`
Timestamp time.Time `json:"timestamp"`
RequiresResponse bool `json:"requires_response,omitempty"`
ResponseTo string `json:"response_to,omitempty"`
}
AgentMessage represents a message exchanged between agents during a mission.
type AgentStatus ¶
type AgentStatus struct {
Name string
Busy bool
TaskCount int
SuccessRate float64
LastActive time.Time
}
AgentStatus tracks the state and performance of a registered agent.
type Config ¶
type Config struct {
MaxWorkers int `json:"max_workers"`
WorkerModel string `json:"worker_model"`
ValidatorModel string `json:"validator_model"`
RepoDir string `json:"repo_dir"`
BaseBranch string `json:"base_branch"`
AutonomyLevel int `json:"autonomy_level"`
SkipValidation bool `json:"skip_validation"`
PerWorkerTimeout time.Duration `json:"per_worker_timeout,omitempty"`
MaxRetriesPerFeat int `json:"max_retries_per_feat,omitempty"`
}
Config controls mission orchestration behavior.
type Feature ¶
type Feature struct {
ID string `json:"id"`
Description string `json:"description"`
ExpectedBehavior string `json:"expected_behavior"`
Branch string `json:"branch"`
WorkerSessionID string `json:"worker_session_id,omitempty"`
Status FeatureStatus `json:"status"`
Handoff *Handoff `json:"handoff,omitempty"`
StartedAt time.Time `json:"started_at,omitempty"`
CompletedAt time.Time `json:"completed_at,omitempty"`
}
Feature is a discrete unit of work assigned to a worker.
type FeatureStatus ¶
type FeatureStatus string
FeatureStatus tracks individual feature progress.
const ( FeaturePending FeatureStatus = "pending" FeatureInProgress FeatureStatus = "in_progress" FeatureCompleted FeatureStatus = "completed" FeatureFailed FeatureStatus = "failed" )
type Handoff ¶
type Handoff struct {
CommitID string `json:"commit_id,omitempty"`
RepoPath string `json:"repo_path,omitempty"`
Summary string `json:"summary"`
FilesChanged []string `json:"files_changed,omitempty"`
TestsPassed bool `json:"tests_passed"`
}
Handoff is the structured report a worker produces upon completion.
type HandoffMessage ¶
type HandoffMessage struct {
FromAgent string
ToAgent string
Reason string
Context string
Task string
Priority int
State map[string]interface{}
Timestamp time.Time
}
HandoffMessage represents a control transfer message between agents.
type HandoffProtocol ¶
type HandoffProtocol struct {
Agents map[string]*AgentCapability
ActiveAgent string
History []HandoffMessage
// contains filtered or unexported fields
}
HandoffProtocol manages typed message-based control transfer between specialized agents.
func NewHandoffProtocol ¶
func NewHandoffProtocol() *HandoffProtocol
NewHandoffProtocol creates a new HandoffProtocol with initialized fields.
func (*HandoffProtocol) BuildHandoffContext ¶
func (hp *HandoffProtocol) BuildHandoffContext(from, to string, task string) *HandoffMessage
BuildHandoffContext automatically builds a HandoffMessage with relevant state for transferring control from one agent to another.
func (*HandoffProtocol) CanHandle ¶
func (hp *HandoffProtocol) CanHandle(agentName, task string) bool
CanHandle checks whether a given agent can handle a task by matching task keywords against the agent's expertise.
func (*HandoffProtocol) EscalateToHuman ¶
func (hp *HandoffProtocol) EscalateToHuman(reason string) *HandoffMessage
EscalateToHuman creates a special handoff message that signals human intervention is needed.
func (*HandoffProtocol) FormatHandoffHistory ¶
func (hp *HandoffProtocol) FormatHandoffHistory() string
FormatHandoffHistory returns a formatted string representation of the handoff history.
func (*HandoffProtocol) GetActiveAgent ¶
func (hp *HandoffProtocol) GetActiveAgent() *AgentCapability
GetActiveAgent returns the currently active agent's capability, or nil if no agent is active.
func (*HandoffProtocol) Handoff ¶
func (hp *HandoffProtocol) Handoff(msg HandoffMessage) error
Handoff transfers control from one agent to another. It validates the target agent exists, transfers context and task, records the handoff in history, and sets the new active agent.
func (*HandoffProtocol) RegisterAgent ¶
func (hp *HandoffProtocol) RegisterAgent(cap AgentCapability)
RegisterAgent adds an agent capability to the protocol.
func (*HandoffProtocol) SelectBestAgent ¶
func (hp *HandoffProtocol) SelectBestAgent(task string) string
SelectBestAgent picks the best agent for a given task by matching task keywords against agent expertise and considering complexity.
type Ledger ¶
type Ledger struct {
Facts []Fact
Plan []PlanItem
Agents map[string]*AgentStatus
CurrentAssignment string
StallCount int
// contains filtered or unexported fields
}
Ledger maintains the shared state of facts, plan, and agents for orchestration.
type LedgerOrchestrator ¶
type LedgerOrchestrator struct {
Ledger *Ledger
MaxStalls int
ReassignThreshold time.Duration
// contains filtered or unexported fields
}
LedgerOrchestrator coordinates multi-agent work using a task ledger, dynamically reassigning work based on progress — inspired by MagenticOne.
func NewLedgerOrchestrator ¶
func NewLedgerOrchestrator() *LedgerOrchestrator
NewLedgerOrchestrator creates a new orchestrator with sensible defaults.
func (*LedgerOrchestrator) AddFact ¶
func (lo *LedgerOrchestrator) AddFact(content, source string, confidence float64)
AddFact records a new discovered fact into the ledger.
func (*LedgerOrchestrator) AddPlanItem ¶
func (lo *LedgerOrchestrator) AddPlanItem(description string, deps []string)
AddPlanItem appends a new plan item with the given description and dependencies.
func (*LedgerOrchestrator) AssignNext ¶
func (lo *LedgerOrchestrator) AssignNext() (*PlanItem, string)
AssignNext finds the next unblocked pending plan item and assigns it to the best available agent. Returns nil, "" if no assignment can be made.
func (*LedgerOrchestrator) DetectStall ¶
func (lo *LedgerOrchestrator) DetectStall() bool
DetectStall checks if any active item has exceeded the ReassignThreshold without progress. Returns true if a stall is detected.
func (*LedgerOrchestrator) FormatLedger ¶
func (lo *LedgerOrchestrator) FormatLedger() string
FormatLedger returns a human-readable summary of the ledger state.
func (*LedgerOrchestrator) Reassign ¶
func (lo *LedgerOrchestrator) Reassign(itemID string) string
Reassign moves a stalled item to a different agent and records a fact. Returns the name of the new agent, or "" if no reassignment is possible.
func (*LedgerOrchestrator) RegisterAgent ¶
func (lo *LedgerOrchestrator) RegisterAgent(name string)
RegisterAgent adds a new agent to the orchestrator's pool.
func (*LedgerOrchestrator) ReportProgress ¶
func (lo *LedgerOrchestrator) ReportProgress(agentName string, itemID string, status string)
ReportProgress updates the status of a plan item and the agent's stats.
func (*LedgerOrchestrator) UpdatePlan ¶
func (lo *LedgerOrchestrator) UpdatePlan(newItems []PlanItem)
UpdatePlan replaces or merges plan items dynamically. Items with matching IDs are updated; new items are appended.
type MemEntry ¶
type MemEntry struct {
Key string `json:"key"`
Value interface{} `json:"value"`
Type string `json:"type"` // "string", "int", "bool", "json", "list"
Owner string `json:"owner"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
Version int `json:"version"`
Readers []string `json:"readers,omitempty"`
}
MemEntry represents a single entry in shared memory.
type MessageBus ¶
type MessageBus struct {
// contains filtered or unexported fields
}
MessageBus coordinates inter-agent communication during mission execution.
func NewMessageBus ¶
func NewMessageBus() *MessageBus
NewMessageBus creates and returns an initialized MessageBus.
func (*MessageBus) Broadcast ¶
func (mb *MessageBus) Broadcast(from, topic, content string)
Broadcast sends a message from one agent to all others.
func (*MessageBus) BuildContextFromMessages ¶
func (mb *MessageBus) BuildContextFromMessages(agentID string, maxTokens int) string
BuildContextFromMessages formats recent relevant messages for injection into an agent's context. It returns a human-readable summary of team communication limited to approximately maxTokens characters.
func (*MessageBus) GetHistory ¶
func (mb *MessageBus) GetHistory(topic string, limit int) []AgentMessage
GetHistory returns messages filtered by topic (or all if topic is empty), limited to the most recent `limit` entries.
func (*MessageBus) Register ¶
func (mb *MessageBus) Register(agentID string) <-chan AgentMessage
Register creates a channel for the given agent to receive messages. Returns a read-only channel the agent can listen on.
func (*MessageBus) ReportConflict ¶
func (mb *MessageBus) ReportConflict(from string, files []string, description string)
ReportConflict notifies all agents about a file conflict so they can coordinate.
func (*MessageBus) ReportDiscovery ¶
func (mb *MessageBus) ReportDiscovery(from, discovery string)
ReportDiscovery shares a useful finding with all agents.
func (*MessageBus) ReportProgress ¶
func (mb *MessageBus) ReportProgress(from string, pct float64, status string)
ReportProgress sends a progress update for coordination.
func (*MessageBus) RequestHelp ¶
func (mb *MessageBus) RequestHelp(from, description string) string
RequestHelp broadcasts a help request and returns the message ID for tracking responses.
func (*MessageBus) Send ¶
func (mb *MessageBus) Send(msg AgentMessage) error
Send delivers a message to a specific agent or broadcasts to all. If msg.To is set, delivers to that specific agent. If msg.To is empty, broadcasts to all registered agents (except sender).
func (*MessageBus) Subscribe ¶
func (mb *MessageBus) Subscribe(agentID, topic string)
Subscribe registers an agent to receive messages for a given topic.
func (*MessageBus) Unregister ¶
func (mb *MessageBus) Unregister(agentID string)
Unregister removes an agent from the message bus and closes its channel.
func (*MessageBus) WaitForResponse ¶
func (mb *MessageBus) WaitForResponse(messageID string, timeout time.Duration) (*AgentMessage, error)
WaitForResponse blocks until a response to the given messageID arrives or timeout elapses.
type Mission ¶
type Mission struct {
ID string `json:"id"`
Prompt string `json:"prompt"`
Dir string `json:"dir"`
Features []Feature `json:"features"`
Status Status `json:"status"`
StartedAt time.Time `json:"started_at"`
CompletedAt time.Time `json:"completed_at,omitempty"`
Config Config `json:"config"`
// contains filtered or unexported fields
}
Mission represents a multi-agent orchestration run.
type PlanFunc ¶
Plan decomposes the mission prompt into features. planFn is called with the prompt and should return a list of features.
type PlanItem ¶
type PlanItem struct {
ID string
Description string
Status string // "pending", "active", "done", "stalled"
AssignedTo string
Dependencies []string
Order int
}
PlanItem represents a single unit of work in the orchestration plan.
type SharedMemory ¶
type SharedMemory struct {
// contains filtered or unexported fields
}
SharedMemory provides a concurrent-safe key-value store for multi-agent workflows, allowing agents to read and write common state without message passing.
func NewSharedMemory ¶
func NewSharedMemory() *SharedMemory
NewSharedMemory creates and returns an initialized SharedMemory instance.
func (*SharedMemory) Clear ¶
func (sm *SharedMemory) Clear()
Clear resets all entries, namespaces, and watchers.
func (*SharedMemory) Delete ¶
func (sm *SharedMemory) Delete(key string, owner string) error
Delete removes an entry from shared memory. Only the owner who wrote the entry is permitted to delete it; otherwise an error is returned.
func (*SharedMemory) Diff ¶
func (sm *SharedMemory) Diff(since time.Time) []MemEntry
Diff returns all entries that have been modified since the given timestamp.
func (*SharedMemory) FormatState ¶
func (sm *SharedMemory) FormatState() string
FormatState returns a human-readable representation of all entries in shared memory, formatted for display in agent context.
func (*SharedMemory) Get ¶
func (sm *SharedMemory) Get(key string) (interface{}, bool)
Get retrieves a value from shared memory by key. Returns the value and a boolean indicating whether the key was found.
func (*SharedMemory) GetBool ¶
func (sm *SharedMemory) GetBool(key string) bool
GetBool retrieves a value as a bool. Returns false if the key does not exist or the value cannot be interpreted as a boolean.
func (*SharedMemory) GetInt ¶
func (sm *SharedMemory) GetInt(key string) int
GetInt retrieves a value as an int. Returns 0 if the key does not exist or the value cannot be interpreted as an integer.
func (*SharedMemory) GetString ¶
func (sm *SharedMemory) GetString(key string) string
GetString retrieves a value as a string. Returns empty string if the key does not exist or the value cannot be converted to a string.
func (*SharedMemory) List ¶
func (sm *SharedMemory) List(namespace string) []MemEntry
List returns all entries belonging to a given namespace.
func (*SharedMemory) Restore ¶
func (sm *SharedMemory) Restore(snapshot map[string]interface{})
Restore populates shared memory from a previously captured snapshot. Existing entries are cleared and replaced with the snapshot contents. All restored entries are assigned owner "snapshot" and version 1.
func (*SharedMemory) Set ¶
func (sm *SharedMemory) Set(key string, value interface{}, owner string)
Set writes a value into shared memory. If the key already exists, the version is incremented and the UpdatedAt timestamp is refreshed. The owner is recorded as the agent that last wrote the entry.
func (*SharedMemory) SetNamespace ¶
func (sm *SharedMemory) SetNamespace(key, namespace string)
SetNamespace assigns a key to a namespace for organizational grouping. A key can belong to multiple namespaces.
func (*SharedMemory) Snapshot ¶
func (sm *SharedMemory) Snapshot() map[string]interface{}
Snapshot returns a shallow copy of all key-value pairs currently in shared memory.
func (*SharedMemory) Watch ¶
func (sm *SharedMemory) Watch(key string) <-chan *MemEntry
Watch returns a channel that receives notifications whenever the specified key is updated. The channel is buffered (size 16) and non-blocking on send.
type WorkerFunc ¶
type WorkerFunc func(ctx context.Context, feature *Feature, missionDir string, cfg Config) (*Handoff, error)
WorkerFunc is the function type that the orchestrator calls for each feature. It receives the feature and mission dir, and returns a handoff or error.
func EngineWorker ¶
func EngineWorker(provider, model, systemPrompt string) WorkerFunc
EngineWorker returns a WorkerFunc that runs an actual engine session in an isolated git worktree for each feature.