coordination

package
v0.14.0 Latest Latest
Warning

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

Go to latest
Published: Nov 8, 2026 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AgentCost

type AgentCost struct {
	AgentID   string
	TokensIn  int64
	TokensOut int64
}

AgentCost tracks token usage for cost accounting.

type AgentInfo

type AgentInfo struct {
	ID        string
	Provider  string
	Role      string
	Model     string
	Namespace string
}

AgentInfo holds metadata about a registered agent.

type Coordinator

type Coordinator interface {
	RegisterAgent(ctx context.Context, info AgentInfo) error
	Heartbeat(ctx context.Context, agentID string) error
	CreateTask(ctx context.Context, spec TaskSpec) (string, error)
	ListTasks(ctx context.Context) ([]Task, error)
	GetTaskResult(ctx context.Context, taskID string) (string, error)
	SendMessage(ctx context.Context, agentID, text string) error
	GetCosts(ctx context.Context) ([]AgentCost, error)
	Close() error
}

Coordinator defines the multi-agent coordination interface. Implementations can be local (in-memory) or remote (Redis-backed).

type LocalCoordinator

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

LocalCoordinator is an in-memory, zero-config coordinator implementation. Data does not survive restarts. Used as the default fallback when Redis is not configured.

func NewLocalCoordinator

func NewLocalCoordinator() *LocalCoordinator

NewLocalCoordinator creates and returns a new in-memory coordinator.

func (*LocalCoordinator) Close

func (lc *LocalCoordinator) Close() error

Close is a no-op for the local coordinator.

func (*LocalCoordinator) CreateTask

func (lc *LocalCoordinator) CreateTask(ctx context.Context, spec TaskSpec) (string, error)

CreateTask generates a new task with a unique ID and stores it.

func (*LocalCoordinator) GetCosts

func (lc *LocalCoordinator) GetCosts(ctx context.Context) ([]AgentCost, error)

GetCosts returns all tracked agent costs.

func (*LocalCoordinator) GetTaskResult

func (lc *LocalCoordinator) GetTaskResult(ctx context.Context, taskID string) (string, error)

GetTaskResult returns the ResultRef if the task is completed, otherwise an error.

func (*LocalCoordinator) Heartbeat

func (lc *LocalCoordinator) Heartbeat(ctx context.Context, agentID string) error

Heartbeat is a no-op for the local coordinator. Liveness tracking is not needed in the in-memory implementation.

func (*LocalCoordinator) ListTasks

func (lc *LocalCoordinator) ListTasks(ctx context.Context) ([]Task, error)

ListTasks returns all tasks sorted by creation time (ascending).

func (*LocalCoordinator) RegisterAgent

func (lc *LocalCoordinator) RegisterAgent(ctx context.Context, info AgentInfo) error

RegisterAgent stores agent metadata.

func (*LocalCoordinator) SendMessage

func (lc *LocalCoordinator) SendMessage(ctx context.Context, agentID, text string) error

SendMessage appends a message to an agent's message queue.

type RedisCoordinator

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

RedisCoordinator implements Coordinator with a Redis backend. Extracted from internal/mcpserver/server.go Redis operations.

func NewRedisCoordinator

func NewRedisCoordinator(redisURL, teamID string) (*RedisCoordinator, error)

NewRedisCoordinator connects to Redis and verifies the connection. teamID defaults to "default" if empty.

func NewRedisCoordinatorFromClient

func NewRedisCoordinatorFromClient(rdb *redis.Client, teamID string) *RedisCoordinator

NewRedisCoordinatorFromClient creates a RedisCoordinator from an existing client. Used for testing with miniredis or pre-configured clients.

func (*RedisCoordinator) Close

func (c *RedisCoordinator) Close() error

func (*RedisCoordinator) CreateTask

func (c *RedisCoordinator) CreateTask(ctx context.Context, spec TaskSpec) (string, error)

func (*RedisCoordinator) GetCosts

func (c *RedisCoordinator) GetCosts(ctx context.Context) ([]AgentCost, error)

func (*RedisCoordinator) GetTaskResult

func (c *RedisCoordinator) GetTaskResult(ctx context.Context, taskID string) (string, error)

func (*RedisCoordinator) Heartbeat

func (c *RedisCoordinator) Heartbeat(ctx context.Context, agentID string) error

func (*RedisCoordinator) ListTasks

func (c *RedisCoordinator) ListTasks(ctx context.Context) ([]Task, error)

func (*RedisCoordinator) RegisterAgent

func (c *RedisCoordinator) RegisterAgent(ctx context.Context, info AgentInfo) error

func (*RedisCoordinator) SendMessage

func (c *RedisCoordinator) SendMessage(ctx context.Context, agentID, text string) error

type Task

type Task struct {
	ID            string
	Status        TaskStatus
	Prompt        string
	RequiredRole  string
	Assignee      string
	DependsOn     []string
	ResultSummary string
	ResultRef     string
	Error         string
	CreatedAt     time.Time
	CompletedAt   time.Time
}

Task represents a unit of work in the coordination system.

type TaskSpec

type TaskSpec struct {
	Prompt       string
	RequiredRole string
	DependsOn    []string
}

TaskSpec defines the request to create a new task.

type TaskStatus

type TaskStatus string

TaskStatus represents the lifecycle state of a task.

const (
	TaskPending    TaskStatus = "pending"
	TaskClaimed    TaskStatus = "claimed"
	TaskInProgress TaskStatus = "in_progress"
	TaskCompleted  TaskStatus = "completed"
	TaskFailed     TaskStatus = "failed"
)

Jump to

Keyboard shortcuts

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