crews

package
v1.3.0 Latest Latest
Warning

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

Go to latest
Published: Feb 26, 2026 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Crew

type Crew struct {
	ID          string                 `json:"id"`
	Name        string                 `json:"name"`
	Description string                 `json:"description"`
	Members     map[string]*CrewMember `json:"members"`
	Tasks       []*CrewTask            `json:"tasks"`
	Process     ProcessType            `json:"process"`
	Verbose     bool                   `json:"verbose"`
	// contains filtered or unexported fields
}

船员代表一组特工一起工作.

func NewCrew

func NewCrew(config CrewConfig, logger *zap.Logger) *Crew

NewCrew创建了新的团队.

func (*Crew) AddMember

func (c *Crew) AddMember(agent CrewAgent, role Role) *CrewMember

添加"成员"为机组增加一名成员.

func (*Crew) AddTask

func (c *Crew) AddTask(task CrewTask)

添加任务给船员添加了任务.

func (*Crew) Execute

func (c *Crew) Execute(ctx context.Context) (*CrewResult, error)

执行与船员一起执行所有任务.

type CrewAgent

type CrewAgent interface {
	ID() string
	Execute(ctx context.Context, task CrewTask) (*TaskResult, error)
	Negotiate(ctx context.Context, proposal Proposal) (*NegotiationResult, error)
}

机组特工的机组接口

type CrewConfig

type CrewConfig struct {
	Name        string
	Description string
	Process     ProcessType
	Verbose     bool
}

CrewConfig配置一个船员.

type CrewMember

type CrewMember struct {
	ID       string         `json:"id"`
	Role     Role           `json:"role"`
	Agent    CrewAgent      `json:"-"`
	Status   MemberStatus   `json:"status"`
	Metadata map[string]any `json:"metadata,omitempty"`
}

船员代表一个船员的特工

type CrewResult

type CrewResult struct {
	CrewID      string                 `json:"crew_id"`
	TaskResults map[string]*TaskResult `json:"task_results"`
	StartTime   time.Time              `json:"start_time"`
	EndTime     time.Time              `json:"end_time"`
	Duration    time.Duration          `json:"duration"`
}

CrewResult载有船员行刑的结果.

type CrewTask

type CrewTask struct {
	ID           string         `json:"id"`
	Description  string         `json:"description"`
	Expected     string         `json:"expected_output"`
	Context      string         `json:"context,omitempty"`
	AssignedTo   string         `json:"assigned_to,omitempty"`
	Dependencies []string       `json:"dependencies,omitempty"`
	Priority     int            `json:"priority"`
	Metadata     map[string]any `json:"metadata,omitempty"`
}

船员任务代表着船员的任务.

type MemberStatus

type MemberStatus string

成员地位代表船员地位。

const (
	MemberStatusIdle    MemberStatus = "idle"
	MemberStatusWorking MemberStatus = "working"
	MemberStatusWaiting MemberStatus = "waiting"
)

type NegotiationResult

type NegotiationResult struct {
	Accepted bool      `json:"accepted"`
	Response string    `json:"response"`
	Counter  *Proposal `json:"counter_proposal,omitempty"`
}

谈判成果是谈判的结果。

type ProcessType

type ProcessType string

ProcessType定义任务处理方式.

const (
	ProcessSequential   ProcessType = "sequential"
	ProcessHierarchical ProcessType = "hierarchical"
	ProcessConsensus    ProcessType = "consensus"
)

type Proposal

type Proposal struct {
	Type       ProposalType   `json:"type"`
	FromMember string         `json:"from_member"`
	ToMember   string         `json:"to_member,omitempty"`
	Task       *CrewTask      `json:"task,omitempty"`
	Message    string         `json:"message"`
	Metadata   map[string]any `json:"metadata,omitempty"`
}

提案是谈判提案。

type ProposalType

type ProposalType string

提案Type定义了提案的类型.

const (
	ProposalTypeDelegate ProposalType = "delegate"
	ProposalTypeAssist   ProposalType = "assist"
	ProposalTypeInform   ProposalType = "inform"
	ProposalTypeRequest  ProposalType = "request"
)

type Role

type Role struct {
	Name            string   `json:"name"`
	Description     string   `json:"description"`
	Goal            string   `json:"goal"`
	Backstory       string   `json:"backstory,omitempty"`
	Skills          []string `json:"skills"`
	Tools           []string `json:"tools,omitempty"`
	AllowDelegation bool     `json:"allow_delegation"`
}

角色定义了代理人在船员中的角色.

type TaskResult

type TaskResult struct {
	TaskID   string `json:"task_id"`
	Output   any    `json:"output"`
	Error    string `json:"error,omitempty"`
	Duration int64  `json:"duration_ms"`
}

TaskResult代表着一项任务的结果.

Jump to

Keyboard shortcuts

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