mission

package
v0.2.0 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AgentCapability added in v0.2.0

type AgentCapability struct {
	Name          string
	Expertise     []string
	Tools         []string
	MaxComplexity int
	Model         string
}

AgentCapability describes a specialized agent's capabilities.

type AgentMessage added in v0.2.0

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 added in v0.2.0

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"`
}

Config controls mission orchestration behavior.

type Fact added in v0.2.0

type Fact struct {
	ID         string
	Content    string
	Source     string
	Confidence float64
	Timestamp  time.Time
}

Fact represents a discovered piece of information during a mission.

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 added in v0.2.0

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 added in v0.2.0

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 added in v0.2.0

func NewHandoffProtocol() *HandoffProtocol

NewHandoffProtocol creates a new HandoffProtocol with initialized fields.

func (*HandoffProtocol) BuildHandoffContext added in v0.2.0

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 added in v0.2.0

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 added in v0.2.0

func (hp *HandoffProtocol) EscalateToHuman(reason string) *HandoffMessage

EscalateToHuman creates a special handoff message that signals human intervention is needed.

func (*HandoffProtocol) FormatHandoffHistory added in v0.2.0

func (hp *HandoffProtocol) FormatHandoffHistory() string

FormatHandoffHistory returns a formatted string representation of the handoff history.

func (*HandoffProtocol) GetActiveAgent added in v0.2.0

func (hp *HandoffProtocol) GetActiveAgent() *AgentCapability

GetActiveAgent returns the currently active agent's capability, or nil if no agent is active.

func (*HandoffProtocol) Handoff added in v0.2.0

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 added in v0.2.0

func (hp *HandoffProtocol) RegisterAgent(cap AgentCapability)

RegisterAgent adds an agent capability to the protocol.

func (*HandoffProtocol) SelectBestAgent added in v0.2.0

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 added in v0.2.0

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 added in v0.2.0

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 added in v0.2.0

func NewLedgerOrchestrator() *LedgerOrchestrator

NewLedgerOrchestrator creates a new orchestrator with sensible defaults.

func (*LedgerOrchestrator) AddFact added in v0.2.0

func (lo *LedgerOrchestrator) AddFact(content, source string, confidence float64)

AddFact records a new discovered fact into the ledger.

func (*LedgerOrchestrator) AddPlanItem added in v0.2.0

func (lo *LedgerOrchestrator) AddPlanItem(description string, deps []string)

AddPlanItem appends a new plan item with the given description and dependencies.

func (*LedgerOrchestrator) AssignNext added in v0.2.0

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 added in v0.2.0

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 added in v0.2.0

func (lo *LedgerOrchestrator) FormatLedger() string

FormatLedger returns a human-readable summary of the ledger state.

func (*LedgerOrchestrator) Reassign added in v0.2.0

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 added in v0.2.0

func (lo *LedgerOrchestrator) RegisterAgent(name string)

RegisterAgent adds a new agent to the orchestrator's pool.

func (*LedgerOrchestrator) ReportProgress added in v0.2.0

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 added in v0.2.0

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 added in v0.2.0

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 added in v0.2.0

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

MessageBus coordinates inter-agent communication during mission execution.

func NewMessageBus added in v0.2.0

func NewMessageBus() *MessageBus

NewMessageBus creates and returns an initialized MessageBus.

func (*MessageBus) Broadcast added in v0.2.0

func (mb *MessageBus) Broadcast(from, topic, content string)

Broadcast sends a message from one agent to all others.

func (*MessageBus) BuildContextFromMessages added in v0.2.0

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 added in v0.2.0

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 added in v0.2.0

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 added in v0.2.0

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 added in v0.2.0

func (mb *MessageBus) ReportDiscovery(from, discovery string)

ReportDiscovery shares a useful finding with all agents.

func (*MessageBus) ReportProgress added in v0.2.0

func (mb *MessageBus) ReportProgress(from string, pct float64, status string)

ReportProgress sends a progress update for coordination.

func (*MessageBus) RequestHelp added in v0.2.0

func (mb *MessageBus) RequestHelp(from, description string) string

RequestHelp broadcasts a help request and returns the message ID for tracking responses.

func (*MessageBus) Send added in v0.2.0

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 added in v0.2.0

func (mb *MessageBus) Subscribe(agentID, topic string)

Subscribe registers an agent to receive messages for a given topic.

func (*MessageBus) Unregister added in v0.2.0

func (mb *MessageBus) Unregister(agentID string)

Unregister removes an agent from the message bus and closes its channel.

func (*MessageBus) WaitForResponse added in v0.2.0

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.

func New

func New(prompt string, cfg Config) *Mission

New creates a new mission from a prompt and configuration.

func (*Mission) Plan

func (m *Mission) Plan(ctx context.Context, planFn PlanFunc) error

func (*Mission) Run

func (m *Mission) Run(ctx context.Context, workerFn WorkerFunc) error

Run executes all features in parallel using workerFn.

func (*Mission) Summary

func (m *Mission) Summary() string

Summary returns a human-readable summary of the mission.

type PlanFunc

type PlanFunc func(ctx context.Context, prompt string) ([]Feature, error)

Plan decomposes the mission prompt into features. planFn is called with the prompt and should return a list of features.

type PlanItem added in v0.2.0

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 added in v0.2.0

type SharedMemory struct {
	Entries    map[string]*MemEntry `json:"entries"`
	Namespaces map[string][]string  `json:"namespaces"` // namespace -> list of keys
	// 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 added in v0.2.0

func NewSharedMemory() *SharedMemory

NewSharedMemory creates and returns an initialized SharedMemory instance.

func (*SharedMemory) Clear added in v0.2.0

func (sm *SharedMemory) Clear()

Clear resets all entries, namespaces, and watchers.

func (*SharedMemory) Delete added in v0.2.0

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 added in v0.2.0

func (sm *SharedMemory) Diff(since time.Time) []MemEntry

Diff returns all entries that have been modified since the given timestamp.

func (*SharedMemory) FormatState added in v0.2.0

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 added in v0.2.0

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 added in v0.2.0

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 added in v0.2.0

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 added in v0.2.0

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 added in v0.2.0

func (sm *SharedMemory) List(namespace string) []MemEntry

List returns all entries belonging to a given namespace.

func (*SharedMemory) Restore added in v0.2.0

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 added in v0.2.0

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 added in v0.2.0

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 added in v0.2.0

func (sm *SharedMemory) Snapshot() map[string]interface{}

Snapshot returns a shallow copy of all key-value pairs currently in shared memory.

func (*SharedMemory) Watch added in v0.2.0

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 Status

type Status string

Status represents the mission lifecycle.

const (
	StatusPlanning   Status = "planning"
	StatusRunning    Status = "running"
	StatusValidating Status = "validating"
	StatusCompleted  Status = "completed"
	StatusFailed     Status = "failed"
)

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.

Jump to

Keyboard shortcuts

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