Documentation
¶
Index ¶
- Variables
- type AgentRunRequest
- type AsterOS
- func (os *AsterOS) AddInterface(iface Interface) error
- func (os *AsterOS) IsRunning() bool
- func (os *AsterOS) Name() string
- func (os *AsterOS) Pool() *core.Pool
- func (os *AsterOS) RegisterAgent(id string, ag *agent.Agent) error
- func (os *AsterOS) RegisterRoom(id string, r *core.Room) error
- func (os *AsterOS) RegisterWorkflow(id string, wf workflow.Agent) error
- func (os *AsterOS) Registry() *Registry
- func (os *AsterOS) RemoveInterface(name string) error
- func (os *AsterOS) Router() *gin.Engine
- func (os *AsterOS) Serve() error
- func (os *AsterOS) Shutdown() error
- type BaseInterface
- func (i *BaseInterface) Name() string
- func (i *BaseInterface) OnAgentRegistered(agent *agent.Agent) error
- func (i *BaseInterface) OnRoomRegistered(room *core.Room) error
- func (i *BaseInterface) OnWorkflowRegistered(wf workflow.Agent) error
- func (i *BaseInterface) Start(ctx context.Context, os *AsterOS) error
- func (i *BaseInterface) Stop(ctx context.Context) error
- func (i *BaseInterface) Type() InterfaceType
- type Interface
- type InterfaceType
- type Options
- type Registry
- func (r *Registry) Clear()
- func (r *Registry) GetAgent(id string) (*agent.Agent, bool)
- func (r *Registry) GetRoom(id string) (*core.Room, bool)
- func (r *Registry) GetWorkflow(id string) (workflow.Agent, bool)
- func (r *Registry) ListAgents() []string
- func (r *Registry) ListAll() []Resource
- func (r *Registry) ListRooms() []string
- func (r *Registry) ListWorkflows() []string
- func (r *Registry) RegisterAgent(id string, ag *agent.Agent) error
- func (r *Registry) RegisterRoom(id string, room *core.Room) error
- func (r *Registry) RegisterWorkflow(id string, wf workflow.Agent) error
- func (r *Registry) UnregisterAgent(id string) error
- func (r *Registry) UnregisterRoom(id string) error
- func (r *Registry) UnregisterWorkflow(id string) error
- type Resource
- type ResourceType
- type RoomJoinRequest
- type RoomLeaveRequest
- type RoomSayRequest
- type WorkflowExecuteRequest
Constants ¶
This section is empty.
Variables ¶
var ( // 配置错误 ErrPoolRequired = errors.New("pool is required") ErrInvalidPort = errors.New("invalid port number") // 资源错误 ErrAgentNotFound = errors.New("agent not found") ErrRoomNotFound = errors.New("room not found") ErrWorkflowNotFound = errors.New("workflow not found") ErrResourceExists = errors.New("resource already exists") // Interface 错误 ErrInterfaceNotFound = errors.New("interface not found") ErrInterfaceExists = errors.New("interface already exists") // 运行时错误 ErrNotRunning = errors.New("asteros is not running") ErrAlreadyRunning = errors.New("asteros is already running") )
Functions ¶
This section is empty.
Types ¶
type AgentRunRequest ¶
type AgentRunRequest struct {
Message string `json:"message" binding:"required"`
Stream bool `json:"stream,omitempty"`
Context map[string]any `json:"context,omitempty"`
}
AgentRunRequest Agent 运行请求
type AsterOS ¶
type AsterOS struct {
// contains filtered or unexported fields
}
AsterOS Aster 框架的统一运行时系统 AsterOS 负责管理所有 Agents、Rooms、Workflows, 并自动生成 REST API 端点,支持多种 Interface。
func (*AsterOS) AddInterface ¶
AddInterface 添加 Interface
func (*AsterOS) RegisterAgent ¶
RegisterAgent 注册 Agent
func (*AsterOS) RegisterRoom ¶ added in v0.13.0
RegisterRoom 注册 Room
func (*AsterOS) RegisterWorkflow ¶
RegisterWorkflow 注册 Workflow
func (*AsterOS) RemoveInterface ¶
RemoveInterface 移除 Interface
type BaseInterface ¶
type BaseInterface struct {
// contains filtered or unexported fields
}
BaseInterface 基础 Interface 实现 提供默认的空实现,子类可以选择性覆盖
func NewBaseInterface ¶
func NewBaseInterface(name string, typ InterfaceType) *BaseInterface
NewBaseInterface 创建基础 Interface
func (*BaseInterface) OnAgentRegistered ¶
func (i *BaseInterface) OnAgentRegistered(agent *agent.Agent) error
OnAgentRegistered Agent 注册事件(默认空实现)
func (*BaseInterface) OnRoomRegistered ¶ added in v0.13.0
func (i *BaseInterface) OnRoomRegistered(room *core.Room) error
OnRoomRegistered Room 注册事件(默认空实现)
func (*BaseInterface) OnWorkflowRegistered ¶
func (i *BaseInterface) OnWorkflowRegistered(wf workflow.Agent) error
OnWorkflowRegistered Workflow 注册事件(默认空实现)
func (*BaseInterface) Start ¶
func (i *BaseInterface) Start(ctx context.Context, os *AsterOS) error
Start 启动 Interface(默认空实现)
type Interface ¶
type Interface interface {
// Name 返回 Interface 名称
Name() string
// Type 返回 Interface 类型
Type() InterfaceType
// Start 启动 Interface
Start(ctx context.Context, os *AsterOS) error
// Stop 停止 Interface
Stop(ctx context.Context) error
// OnAgentRegistered Agent 注册事件
OnAgentRegistered(agent *agent.Agent) error
// OnRoomRegistered Room 注册事件
OnRoomRegistered(room *core.Room) error
// OnWorkflowRegistered Workflow 注册事件
OnWorkflowRegistered(wf workflow.Agent) error
}
Interface AsterOS 接口抽象 Interface 定义了 AsterOS 与外部系统交互的标准接口
type InterfaceType ¶
type InterfaceType string
InterfaceType Interface 类型
const ( InterfaceTypeHTTP InterfaceType = "http" // HTTP REST API InterfaceTypeA2A InterfaceType = "a2a" // Agent-to-Agent InterfaceTypeAGUI InterfaceType = "agui" // Agent GUI InterfaceTypeSlack InterfaceType = "slack" // Slack 集成 )
type Options ¶
type Options struct {
// 基本配置
Name string // AsterOS 实例名称
Port int // HTTP 服务端口,默认 8080
// 核心组件
Pool *core.Pool // Pool 实例(必需)
// 自动发现
AutoDiscover bool // 是否自动发现和注册资源,默认 true
// API 配置
APIPrefix string // API 路径前缀,默认 ""
EnableCORS bool // 是否启用 CORS,默认 true
// 安全配置
EnableAuth bool // 是否启用认证,默认 false
APIKey string // API Key(如果启用认证)
// 监控配置
EnableMetrics bool // 是否启用 Prometheus 指标,默认 true
EnableHealth bool // 是否启用健康检查,默认 true
// 日志配置
EnableLogging bool // 是否启用请求日志,默认 true
LogLevel string // 日志级别:debug, info, warn, error,默认 info
}
Options AsterOS 配置选项
type Registry ¶
type Registry struct {
// contains filtered or unexported fields
}
Registry 资源注册表
func (*Registry) GetWorkflow ¶
GetWorkflow 获取 Workflow
func (*Registry) ListWorkflows ¶
ListWorkflows 列出所有 Workflows
func (*Registry) RegisterAgent ¶
RegisterAgent 注册 Agent
func (*Registry) RegisterRoom ¶ added in v0.13.0
RegisterRoom 注册 Room
func (*Registry) RegisterWorkflow ¶
RegisterWorkflow 注册 Workflow
func (*Registry) UnregisterAgent ¶
UnregisterAgent 注销 Agent
func (*Registry) UnregisterRoom ¶ added in v0.13.0
UnregisterRoom 注销 Room
func (*Registry) UnregisterWorkflow ¶
UnregisterWorkflow 注销 Workflow
type Resource ¶
type Resource struct {
ID string // 资源 ID
Name string // 资源名称
Type ResourceType // 资源类型
Data any // 资源数据(Agent、Room 或 Workflow)
}
Resource 资源信息
type ResourceType ¶
type ResourceType string
ResourceType 资源类型
const ( ResourceTypeAgent ResourceType = "agent" ResourceTypeRoom ResourceType = "room" ResourceTypeWorkflow ResourceType = "workflow" )
type RoomJoinRequest ¶ added in v0.13.0
type RoomJoinRequest struct {
Name string `json:"name" binding:"required"`
AgentID string `json:"agent_id" binding:"required"`
}
RoomJoinRequest Room 加入请求
type RoomLeaveRequest ¶ added in v0.13.0
type RoomLeaveRequest struct {
Name string `json:"name" binding:"required"`
}
RoomLeaveRequest Room 离开请求
type RoomSayRequest ¶ added in v0.13.0
type RoomSayRequest struct {
From string `json:"from" binding:"required"`
Text string `json:"text" binding:"required"`
}
RoomSayRequest Room 发送消息请求
type WorkflowExecuteRequest ¶
type WorkflowExecuteRequest struct {
Message string `json:"message" binding:"required"`
Context map[string]any `json:"context,omitempty"`
}
WorkflowExecuteRequest Workflow 执行请求